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? Is one library missing any functionality that the other covers?
How does ClojureQL compare to clojure.contrib.sql?
3.4k Views Asked by clizzin At
1
There are 1 best solutions below
Related Questions in SQL
- SQL schema for a fill-in-the-blank exercise
- Hibernate: JOIN inheritance question - why the need for two left joins
- What's supposed to be the problem in this query?
- Compare fields in two tables
- How to change woocomerce or full wordpress currency with value from USD to AUD
- Dynamic query creation with Array like implementation
- SQL query to get student enrolled in this month in a course - Moodle
- SQL LAG() function returning 0 for every row despite available previous rows
- Convert C# DateTime.Ticks to Bigquery DateTime Format
- Use row values from another table to select them as columns and establish relations between them (pivot table)
- SQL: Generate combination table based on source and destination column from same table
- how to use system's environnement variables in sql script
- PHP fetchAll on JOIN
- Multitable joining in Sql
- How to display name starting from 'z' by using BETWEEN cmd only?
Related Questions in CLOJURE
- SSE implementation in Pedestal using individual channel per user
- Within a Clojure project using deps.edn, where is the package name and version tracked?
- How can I update and iterate the sub maps and update map into different location of map at the same time in clojure
- Out of memory in clojure - Nested reduce on Lazy Sequence
- Mac OS X - Brew installed Leiningen permission error / wrong directory
- Consume SpiceDB LookupResources gRPC stream from Clojure using Java gRPC library
- Server sent events in pedestal returns empty response
- How to make quarkus find my Clojure classes?
- Looking for a Clojure/LISP equivalent to Scons
- lazily calling functions for infinite sequence clojure
- Issue with Kafka in Clojure Repl for Arm64 M1
- Unable write parser where the AST can be turned into Clojure code
- Naming convention for simbol of clojure.core/atom, like !foo in Clojure
- How to nest a sequence of layered steps?
- How to type hint a float?
Related Questions in CLOJURE-CONTRIB
- Problems while creating a deps.edn file
- How do you append environment variables to a java clojure cli?
- Clojure read Oracle Blob
- How to accept additional arguments for an option in tools.cli?
- How to show error on missing parameters for options?
- clojure-api: Single main clj for multiple API handlers
- java.lang.StackOverflowError in clojure.java.data from-java
- How to use getInputStream() to get POST request data in Clojure. I am getting an NullPointerException in Reflector
- Can You Mix ClojureScript and JVM-Clojure in The Same Project?
- Adding key- value pairs to maps in a list of maps from another list of maps in clojure
- Clojure cmdline start use maven pom file
- Don't know how to create ISeq from: clojure.lang.Var error
- how to implement any genetic ant finding food in Push,Clojush,Clojure?
- Clojure normalize function runtime error
- How to build clojure_contrib with Clojure v 1.6?
Related Questions in CLOJUREQL
- Clojure QL : running plain SQL queries
- clojureql query with sub-select
- how to insert a default value into a column using clojureql
- Clojureql - Can't take value of a macro (clojure)
- How to do SELECT ... WHERE ... IN in ClojureQL?
- Getting the HAVING clause in ClojureQL query
- How can I add an index to a table using ClojureQL?
- ORM for clojure?
- Just generate SQL from ClojureQL's disj! conj! and update-in! functions
- clojureql select between two dates
- In ClojureQL how can I make a where clause case insensitive?
- clojureql, open-global and with-results
- How can I change a list to code in a Clojure macro?
- How does ClojureQL compare to clojure.contrib.sql?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
ClojureQL and clojure.contrib.sql are two quite different libraries. The first aims to implement the primitives from relational algebra and compile those to SQL92. It also offer an extensible compiler that can be adapted to database specific SQL dialect. The second is a lightweight set of helpers for using JDBC from Clojure code.
Querying
clojure.contib.sql
With clojure.contib.sql, you'll have to use SQL to write your queries. Here's an example:
ClojureQL
As ClojureQL is mostly a query language, it provides a rich Clojure-based DSL to create SQL queries. I'll skip advanced examples and only show you the ClojureQL equivalent to the above query:
You can express queries of arbitrary complexity with both, but contrib.sql require you to write SQL code. Take note that ClojureQL DSL main advantage over standard SQL is composability. Its
tablefunction returns aRTableobject representing a query on the specified table, you can chain other ClojureQL function over that object to create the query that you need, then dereference it to execute it. Refer to ClojureQL examples page and documentation for more information on how to create more complex queries.Inserting, Updating and Deleting
clojure.contib.sql
clojure.contrib.sql provides a comprehensive set of functions to insert, update and delete rows.
(insert-records table & records), where records are maps(insert-rows table & rows), where rows are vectors(insert-values table column-names & value-groups)(update-values table where-params record)(update-or-insert-values table where-params record)(delete-rows table where-params)ClojureQL
ClojureQL provides three
RTablemethods to manipulate the specified table data:conj!which is a shorcut to contrib.sql'sinsert-recordsdisj!which is a shorcut to contrib.sql'sdelete-rowsupdate-in!which is similar to contrib.sql'supdate-or-insert-valuesThese have the advantage of using ClojureQL predicates syntax, but for now this part of ClojureQL is not generating database agnostic SQL as it's separated from the compiler. I intend to fix that by merging code from another library I've written in the more-or-less near future.
Schema Manipulation
clojure.contib.sql
clojure.contrib.sql only provides
create-tableanddrop-tablefor creating and removing tables. Note that these are very simple functions that won't make your code portable. To alter a table you'll need to send SQLALTERstatements using thedo-commandsfunction.ClojureQL
No schema manipulation helpers provided.
Lobos (shameless plug ;-)
This is a library I wrote to plug the hole left by these two libraries. It's a work in progress, but you already get a Clojure DSL to send any DDL statements in a database agnostic way.
Here's a basic example for creating a table:
And altering it:
You can get more information on this library by visiting the website or the github page. It aims to provides higher-level functionality like migrations and declarative schema manipulation.
Others
clojure.contrib.sql has a couple extra lower-level helpers, see the complete documentation
There's more to say about how these libraries handle database connections but I'll leave that for another day!
P.S.: Note that both ClojureQL and Lobos are relatively young libraries that still need some work. Both descent from the original ClojureQL project which was a DSL covering the whole SQL language. ClojureQL already have a stable API, but only provide a SQL92 compatible compiler. Lobos has compiler support for multiple databases. but is still in active development and its API can still change.
Update: I've made some changes after a suggestion from Lau. ClojureQL itself doesn't aim to be database-agnostic, but provide the means for users to replace the compiler by a database-specific one. Note that the DML part of SQL is much more standardize than the DDL part.