Created
August 21, 2023 15:12
-
-
Save igrishaev/ca3e68a6d8347bd57921bfefe8577742 to your computer and use it in GitHub Desktop.
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
(ns repl | |
(:require | |
[pg.client :as pg])) | |
(def config | |
{:host "127.0.0.1" | |
:port 10150 | |
:user "test" | |
:password "test" | |
:database "test"}) | |
(pg/with-connection [conn config] | |
(pg/query conn "select 1 as one")) | |
(let [conn (pg/connect config) | |
data (pg/query conn "select 1 as one")] | |
(pg/terminate conn) | |
data) | |
(with-open [conn (pg/connect config)] | |
(pg/query conn "select 1 as one")) | |
(pg/execute "insert into users (name, age) values ($1, $2), ($3, $4) returning id" ["Ivan" 37 "Juan" 38]) | |
(def sql "select * from users where id = $1") | |
(pg/execute conn sql [1]) | |
(pg/execute conn sql [2]) | |
(let [query "select * from users where id = $1"] | |
data1 (pg/execute conn query [1]) | |
data1 (pg/execute conn query [2]) | |
{:data1 data1 | |
:data1 data1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment