Created
November 9, 2011 20:10
-
-
Save davidkrisch/1352820 to your computer and use it in GitHub Desktop.
Connect to hsqldb with Clojure and korma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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