Created
November 26, 2013 07:10
-
-
Save devrimbaris/7654473 to your computer and use it in GitHub Desktop.
H2 Database connection with SQL Korma in Clojure
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
;;; 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