Created
January 8, 2013 14:36
-
-
Save bouzuya/4484208 to your computer and use it in GitHub Desktop.
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
(require '[clojure.java.jdbc :as sql]) | |
(def db | |
"postgresql://postgres:postgres@localhost:5432/shouter") | |
(sql/with-connection db | |
(try (sql/drop-table :testing) (catch Exception _))) | |
(sql/with-connection db | |
(sql/create-table :testing [:data :text])) | |
(sql/with-connection db | |
(sql/insert-rows | |
:testing | |
["Hello, world!"] | |
["Hello, PostgreSQL!"])) | |
(sql/with-connection db | |
(sql/with-query-results results | |
["select * from testing"] | |
(into [] results))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://devcenter.heroku.com/articles/clojure-web-application#connecting-to-postgresql-with-clojurejavajdbc
Clojure から RDBMS を操作するため、上記 URL を写経 + 一部改変。 PostgreSQL を使った例。