Questions tagged [clojureql]

ClojureQL is an alternative SQL library for Clojure.

ClojureQL is an abstraction layer sitting on top of standard low-level JDBC SQL integration. It let's you interact with a database through a series of objects which work as Clojure data type.

ClojureQL is modeled around the primitives defined in Relational Algebra. http://en.wikipedia.org/wiki/Relational_algebra

For the user this means that all queries compose and are never executed unless dereferenced or called with a function that has the ! suffix.

As a help for debugging, wrap your statements in (binding [debug true]) to see the compiled SQL statement printed to stdout.

14 questions
40
votes
8 answers

ORM for clojure?

I was reading this site about the clojure web stack: http://brehaut.net/blog/2011/ring_introduction and it has this to say about ORM for clojure: "There are no SQL/Relational DB ORMs for Clojure for obvious reasons." The obvious reason I can see is…
Kevin
  • 24,871
  • 19
  • 102
  • 158
25
votes
1 answer

How does ClojureQL compare to clojure.contrib.sql?

It looks like each one covers the basic cases like selecting certain columns and filtering by predicate pretty well, but I'm wondering how each compares for more advanced cases. Is it easier to express complex queries in one vis-à-vis the other? …
clizzin
  • 1,236
  • 13
  • 15
6
votes
1 answer

clojureql, open-global and with-results

Just trying to understand the purpose of clojureql's open-global and with-results. I started by reading this overview: How does ClojureQL compare to clojure.contrib.sql? I thought for some reason that open-global would replace sql/with-connection,…
Kevin
  • 24,871
  • 19
  • 102
  • 158
5
votes
2 answers

clojureql select between two dates

How would I use clojureql to select between two dates? Hopefully something like this: @(-> (table :abc) (select (where (between d1 d2))))
Kevin
  • 24,871
  • 19
  • 102
  • 158
3
votes
2 answers

Clojureql - Can't take value of a macro (clojure)

I need to generate the following: (clojureql.core/join (clojureql.core/table db :tableA) (clojureql.core/table db :tableA) (clojureql.core/where (apply and (= :tableA.id :tableB.id) [(apply or [(clojureql.predicates/in…
Ron P
  • 225
  • 2
  • 7
3
votes
2 answers

How can I add an index to a table using ClojureQL?

Using any clojure database/orm library, how can I create an index in a database? I can't seem to find any relevant examples. (I'm most interested in ClojureQL and clojure.java.jdbc, since I'm currently using those). EDIT: OK, so I figured out a…
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
3
votes
1 answer

Just generate SQL from ClojureQL's disj! conj! and update-in! functions

Is there a way to just generate the sql queries from ClojureQL's disj! conj! and update-in! functions, instead of executing them directly ?
NielsK
  • 6,886
  • 1
  • 24
  • 46
3
votes
1 answer

In ClojureQL how can I make a where clause case insensitive?

In ClojureQL how can I make a where clause case insensitive? I am trying to add UPPER or something to do this in the where clause but I can't figure out how to do this
yazz.com
  • 57,320
  • 66
  • 234
  • 385
3
votes
2 answers

How can I change a list to code in a Clojure macro?

I have the following macro: (defmacro ss [x] `(clojureql.core/select (clojureql.core/table db "users_table") (clojureql.core/where ~x) ) ) (macroexpand '(ss '(= :type "special"))) : but it produces : (clojureql.core/select…
yazz.com
  • 57,320
  • 66
  • 234
  • 385
2
votes
1 answer

how to insert a default value into a column using clojureql

I have a postgre table with "id" as SERIAL(auto-increment column), "name" and "instruction" columns. I'm trying to insert into it as: (ql/conj! recipe-table {:id nil :name "a" :instructions "b"}) *Evaluation aborted (ql/conj! recipe-table {:id…
Gabriel Tudor
  • 311
  • 2
  • 8
2
votes
1 answer

How to do SELECT ... WHERE ... IN in ClojureQL?

I just worked this one out. Since it's not in the documentation and needs you to dig into the source, this seemed the right venue for the solution. In ClojureQL, how do you create a query like: SELECT * from foo where id in (1, 5, 7);
Jim Downing
  • 1,481
  • 12
  • 29
2
votes
0 answers

clojureql query with sub-select

Given a table with the following structure: CREATE TABLE transitions (id INT, ordering INT, item_id INT, action_id INT) Is it possible to get ClojureQL to generate a query like this one: SELECT a.item_id, a.action_id FROM transitions a WHERE…
Tom
  • 4,742
  • 25
  • 32
1
vote
1 answer

Getting the HAVING clause in ClojureQL query

I'm trying to build the following query in ClojureQL: SELECT ixIso, MIN(IF(dtDespatched, fQuantity, 0)) AS quantity FROM IsoItem WHERE fQuantity > 0 GROUP BY ixIso HAVING quantity < 1 I've been trying variations of the following code, basing…
Mike
  • 3,356
  • 3
  • 29
  • 27
0
votes
1 answer

Clojure QL : running plain SQL queries

are there any ways to perform the following queries in clojureql ? : insert into table1(id, name, age) select id, name, age from table2 create table t1 (id int, name varchar(50), age varchar(100)); drop table table3; analyze table4; or is there…
Attilah
  • 17,632
  • 38
  • 139
  • 202