Skip to content

Instantly share code, notes, and snippets.

@devrimbaris
Created November 26, 2013 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devrimbaris/7654473 to your computer and use it in GitHub Desktop.
Save devrimbaris/7654473 to your computer and use it in GitHub Desktop.
H2 Database connection with SQL Korma in Clojure
;;; load this file from
;;; path_to_project.clh>emacs src\emlak\korma.clj
;;; This will enable the classpath libraries to be seen
;;; I have installed h2 from setup program, I guess this installs the test database
;;; Users table with columns "first" and "last" should be prepared beforehand
;;; for in memory database the subname should be mem:dbName
;;; got the original gist from someone else...
(ns deneme.core
(:use [korma.db])
(:use [korma.core])
(:use [clojure.test])
)
(defdb mydb {:classname "org.h2.Driver"
:subprotocol "h2"
:subname "~/test"
:user "sa"
:password ""})
(defentity users)
(deftest insert-select
(is (= (do
(-> (insert "USERS")
(values {:first "chris" :last "granger"}))
(select users) ) "bleh")))
(select "USERS")
(insert "USERS"
(values [{:FIRST "john" :LAST "doe"}
{:FIRST "jane" :LAST "doe"}]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment