Questions tagged [sqlkorma]

Korma is a domain specific language for Clojure that takes the pain out of working with your favorite RDBMS.

Korma is a domain specific language for Clojure that takes the pain out of working with your favorite RDBMS.

Built for speed and designed for flexibility, Korma provides a simple and intuitive interface to your data.

29 questions
4
votes
3 answers

Clojure thread-first with filter function

I'm having a problem stringing some forms together to do some ETL on a result set from a korma function. I get back from korma sql: ({:id 1 :some_field "asd" :children [{:a 1 :b 2 :c 3} {:a 1 :b 3 :c 4} {:a 2 :b 2 :c 3}] :another_field "qwe"}) I'm…
OnResolve
  • 4,016
  • 3
  • 28
  • 50
4
votes
1 answer

How to convert korma select results to json for a rest service (compojure)?

I am using compojure, cheshire and korma (and postgre db) for creating a rest service. I've created a table with two string fields (name and description) with such structure: (defentity posts (pk :id) (table :posts) (entity-fields :name…
Curiosity
  • 651
  • 1
  • 5
  • 12
4
votes
1 answer

Sanitising database inputs in Clojure with Korma

I'm using Korma behind a RESTful API, and it occurs to me that I'm passing user-submitted values through to my (insert)calls. Is there a nice way in Clojure to protect against SQL injection attacks? Korma generates SQL in a pretty straightforward…
Conan
  • 2,288
  • 1
  • 28
  • 42
4
votes
1 answer

Select no fields from table in Korma

I'm trying to do a join across a number of tables (three plus a join table in the middle). I think korma is lazily evaluating the last join. What I'm trying to do is to add a condition that restricts the results of the first table in the join, but…
Conan
  • 2,288
  • 1
  • 28
  • 42
3
votes
1 answer

Imitate partitions/window functions in sqlkorma

I am trying to call the equivalent of this function using sqlkorma, and have not found the equivalent of a partition in the documentation (http://sqlkorma.com/docs): SELECT * FROM ( SELECT DISTINCT cgi, scgi, c.id, c.name, c.address,…
Monica
  • 41
  • 7
3
votes
2 answers

Timezone issues with MySQL and clj-time

I have a table in MySQL. create table demo ( theDate datetime ); I insert two dates, one in daylight saving time, one not. (require '[clj-time.core :as t]) (require '[clj-time.coerce :as coerce]) (require '[korma.core :as k]) (k/insert :demo…
Joe
  • 46,419
  • 33
  • 155
  • 245
3
votes
1 answer

Exact usage of `oracle` function in Korma and the meaning of clojure code?

I'm trying to connect to Oracle database using Korma. First I tried to use this code and successfully connected. (defdb korma-db {:classname "oracle.jdbc.OracleDriver" :subprotocol "oracle" :subname "thin:@my.oracle.db:1521:testdb" :user…
ntalbs
  • 28,700
  • 8
  • 66
  • 83
3
votes
2 answers

clojure sqlkorma library: out of memory error

I'm doing what I thought was a fairly straightforward task: run a sql query (over about 65K rows of data) using sqlkorma library (http://sqlkorma.com), and for each row transforming it in some way, and then writing to CSV file. I don't really think…
Kevin
  • 24,871
  • 19
  • 102
  • 158
2
votes
1 answer

Using non-standard postgres operators with SQL Korma

Some complex features of Postgres utilize operators that are not part of the SQL standard. One simple example is the set of POSIX regular expression operators; I need them to include a where clause expression that utilizes word boundaries. Let's…
Brad Koch
  • 19,267
  • 19
  • 110
  • 137
1
vote
1 answer

Korma - join on a sub select but how do I specify an alias?

I would like to assign an alias to the subselect in this query: (-> (korma/select* table_a) (korma/join (korma/subselect table_b (korma/fields :id (korma/raw "COUNT(*) AS count")) (korma/group :id)) …
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
2 answers

Missing FROM-clause entry for table?

When I select a specific field from a table in a has-many relationship I get an exception like this: org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table \"bar\" Here are the relationships I have defined: (declare foo…
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
1 answer

select's fields function of korma does not reject colums?

I play around with clojure and its korma library using an sqlite3 database on windows. I follow an example of the 7web book. It introduces the select* function and its friends. But using the fields function adds fields instead of restricting. ;;…
sschmeck
  • 7,233
  • 4
  • 40
  • 67
1
vote
1 answer

With being ignored by korma (clojure)

I have the following code: (defentity users (database korma-db) (has-many tags)) (defentity tags (database korma-db) (belongs-to users)) (-> (select* users) (with tags) (fields :address) (where {:id 1}) (as-sql)) and it…
Ryan Jenkins
  • 878
  • 8
  • 16
1
vote
2 answers

Can Clojure Korma produce WITH - RETURNING query in Postgres?

I'm trying to reproduce this query from the Postgres docs: WITH moved_rows AS ( DELETE FROM products WHERE "date" >= '2010-10-01' AND "date" < '2010-11-01' RETURNING * ) INSERT INTO products_log SELECT * FROM…
klozovin
  • 2,363
  • 2
  • 22
  • 30
0
votes
1 answer

How to I correctly define a foreign key for a SQLKorma entity?

When I run a simple query with the below entity configuration. SqlKorma generates a query and tried to join table_b with table_a, but it is using a field which doesn't exist? SELECT "table_a"."token", "table_a"."first-name", "table_a"."last-name",…
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
2