Created
January 17, 2024 05:16
-
-
Save jacoobes/cdc6f2119ca1039a2f71eaa57eca7070 to your computer and use it in GitHub Desktop.
sqlite setup and clojure
This file contains hidden or 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.edn | |
;{:paths ["src"] | |
;:deps {io.pedestal/pedestal.service {:mvn/version "0.5.9"} | |
; io.pedestal/pedestal.route {:mvn/version "0.5.9"} | |
; io.pedestal/pedestal.immutant {:mvn/version "0.5.9"} | |
; org.slf4j/slf4j-simple {:mvn/version "1.7.32"} | |
; environ/environ {:mvn/version "1.2.0"} | |
; org.xerial/sqlite-jdbc {:mvn/version "3.7.2" } | |
; com.github.seancorfield/next.jdbc {:mvn/version "1.3.909"} | |
; com.github.seancorfield/honeysql {:mvn/version "2.5.1103"} | |
; }} | |
$ clj | |
user=> (require '[next.jdbc :as jdbc]) | |
nil | |
user=> (def db | |
{:classname "org.sqlite.JDBC" | |
:dbtype "sqlite" | |
:dbname "database.db" | |
:host :none | |
}) | |
#'user/db | |
user=> (def ds (jdbc/get-datasource db)) | |
#'user/ds | |
user=> (jdbc/execute! ds [" | |
create table address ( | |
id int auto_increment primary key, | |
name varchar(32), | |
email varchar(255) | |
)"]) | |
[#:next.jdbc{:update-count 0}] | |
user=> (jdbc/execute! ds [" | |
insert into address(name,email) | |
values('Sean Corfield','[email protected]')"]) | |
[#:next.jdbc{:update-count 1}] | |
user=> (jdbc/execute! ds ["select * from address"]) | |
[#:address{:id nil, :name "Sean Corfield", :email "[email protected]"}] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment