Skip to content

Instantly share code, notes, and snippets.

@davidkrisch
Created November 9, 2011 20:10
Show Gist options
  • Save davidkrisch/1352820 to your computer and use it in GitHub Desktop.
Save davidkrisch/1352820 to your computer and use it in GitHub Desktop.
Connect to hsqldb with Clojure and korma
(comment Snippet of clojure to show how to connect to, insert, and query hsqldb)
(use 'korma.db)
(use 'korma.core)
(comment
The defdb call below assumes the following:
1. hsqldb has been started:
java -cp ../hsqldb/lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 xdb
2. hsqldb drivers have been added to project.clj's ":dependency" vector
[org.hsqldb/hsqldb "2.2.4"]
3. korma has been added to project.cls's ":dependency" vector
[korma "0.2.1"]
4. The schema_migrations table exists with an integer versions column
)
(defdb hsql
{:classname "org.hsqldb.jdbc.JDBCDriver"
:subprotocol "hsqldb"
:subname "hsql://localhost:9001/xdb"})
(defentity schema_migrations
(table :schema_migrations)
(entity-fields :version)
(database hsql))
(insert schema_migrations
(values {:version 12}))
(select schema_migrations
(limit 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment