This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-01
Channels
- # adventofcode (30)
- # announcements (51)
- # aws (27)
- # babashka (1)
- # beginners (16)
- # calva (6)
- # cider (10)
- # clj-kondo (2)
- # clojure (94)
- # clojure-dev (27)
- # clojure-italy (1)
- # clojure-taiwan (1)
- # clojure-uk (5)
- # clojurescript (18)
- # clojutre (2)
- # cursive (14)
- # data-science (8)
- # emacs (2)
- # joker (5)
- # off-topic (3)
- # shadow-cljs (31)
- # sql (2)
- # vim (2)
- # yada (11)
I tried setting column, [:data] in my case, I had some errors, going to try wrap the object is a map like that
beautiful, it works, @hiredman thank you! This is a public catalog of producs I'm updating peridically (take 10 just for debugging)
(defn atomically-update-catalog [new-items]
(jdbc/with-db-transaction [trans-conn @db]
(jdbc/db-do-commands trans-conn
"DROP TABLE IF EXISTS catalog"
;; (jdbc/drop-table-ddl :catalog)
(jdbc/create-table-ddl :catalog
[:id "serial" "NOT NULL" "PRIMARY KEY"]
[:data "json" "NOT NULL"]))
(apply jdbc/insert! trans-conn :catalog new-items)))
(let [options {:headers {"Content-Type" "application/x-www-form-urlencoded"}}
{:keys [status error body]} @(http/post const/feed-url options)]
(if error
(println "Failed, exception is " error)
(-> (mapv #(hash-map :data (pg-types/map->parameter % :json))
(take 10 (-> body json/read-json)))
atomically-update-catalog)))
nice to see that when I query the items in clojure, I get them in EDN! Nice!