Skip to content

Instantly share code, notes, and snippets.

@thirdknife
Last active June 7, 2016 08:09
Show Gist options
  • Save thirdknife/620261608eab24d17fcc064f48f801c3 to your computer and use it in GitHub Desktop.
Save thirdknife/620261608eab24d17fcc064f48f801c3 to your computer and use it in GitHub Desktop.
fn.clj
(ns fs.core
(:require [clojure.java.jdbc :as sql]))
(let [db-protocol "file"
db-host "/Users/shakeel/Desktop"
db-name "fs"]
(def db {:classname "org.h2.Driver" ; must be in classpath
:subprotocol "h2"
:subname (str db-protocol "://" db-host "/" db-name)
:user "sa"
:password ""}))
(defn create-blogs
"Create a table to store blog entries"
[]
(sql/create-table-ddl
:blogs
([:id :int "PRIMARY KEY" "AUTO_INCREMENT"]
[:title "varchar(255)"]
[:body :text])))
(sql/with-db-connection
[con-db db]
(sql/with-db-transaction
(create-blogs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment