Skip to content

Instantly share code, notes, and snippets.

@igrishaev
Created August 21, 2023 15:12
Show Gist options
  • Save igrishaev/ca3e68a6d8347bd57921bfefe8577742 to your computer and use it in GitHub Desktop.
Save igrishaev/ca3e68a6d8347bd57921bfefe8577742 to your computer and use it in GitHub Desktop.
(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