Created
June 22, 2020 11:32
-
-
Save codonnell/51d87e6a9f85607525142c21e8721e1a to your computer and use it in GitHub Desktop.
Honeysql + clojure.java.jdbc returning example
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
(ns returning-example.core | |
(:require [clojure.java.jdbc :as jdbc] | |
[honeysql.core :as sql] | |
[honeysql.format] | |
[honeysql-postgres.format])) | |
(def db-spec | |
{:dbtype "postgresql" | |
:dbname "postgres" | |
:user "postgres" | |
:password "password" | |
:port 25432}) | |
(comment | |
(jdbc/execute! db-spec ["CREATE TABLE my_table (id serial primary key, v text)"]) | |
(jdbc/query db-spec ["SELECT * FROM my_table"]) | |
(jdbc/query db-spec (sql/format {:insert-into :my_table | |
:values [{:v "test"} | |
{:v "test2"}] | |
:returning [:id :v]})) | |
) |
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
{:deps | |
{org.clojure/java.jdbc {:mvn/version "0.7.11"} | |
honeysql {:mvn/version "1.0.444"} | |
nilenso/honeysql-postgres {:mvn/version "0.2.6"} | |
org.postgresql/postgresql {:mvn/version "42.2.12"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment