This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-28
Channels
- # adventofcode (12)
- # announcements (1)
- # asami (18)
- # aws (1)
- # babashka (20)
- # beginners (80)
- # calva (11)
- # cider (10)
- # circleci (5)
- # cljsrn (2)
- # clojure (37)
- # clojure-australia (15)
- # clojure-europe (32)
- # clojure-nl (2)
- # clojure-uk (26)
- # clojured (7)
- # clojurescript (10)
- # clojurewerkz (3)
- # cursive (45)
- # data-science (12)
- # datomic (3)
- # emacs (8)
- # events (3)
- # fulcro (23)
- # graphql (5)
- # helix (3)
- # jobs (1)
- # jobs-discuss (1)
- # juxt (3)
- # lsp (12)
- # malli (4)
- # meander (4)
- # reagent (11)
- # releases (1)
- # shadow-cljs (28)
- # sql (35)
- # tools-deps (9)
- # xtdb (25)
I’m interested in trying Asami and would be interested in knowing some typical setups. Haven’t worked with in-memory only databases much, so… do you import from disk/DB (or wherever) on start and go from there, or what is a typical usecase? 🙂
For in-memory stores, when I’m saving a lot of data, I’ll do an export-data to a file, and import-data when I restart
Thanks, great 🙂 So, haven’t looked but is there built-in import/export functionality?
Btw, read most of you background articles. Fascinating and a great read. Thanks for sharing so much, really interesting! 😄
For loading from JSON, XML or other messy files, that would be regular parsing and a lot of transacts, right?
You can insert statements (triples) easily enough, but we tend to not do that. Instead we go with objects. These are deconstructed into triples, and they all go in together in a transaction
(require '[asami.core :as d])
(require '[cheshire.core :as json])
(require '[ :as io])
(def bundle-dir (io/file "/data/bundle"))
(def bundles (map (comp json/parse-stream io/reader) (.listFiles bundle-dir)))
(def tx2 @(d/transact conn {:tx-data bundles}))
each file in the bundle directory held a single map object, and it was several MB of data
To load triples, I tend to just write them as edn, and load them that way.
e.g. triples.edn
[[#a/n[123] :type :person]
[#a/n[123] :first-name "Betty"]
[#a/n[123] :last-name "Rubble"]
[#a/n[123] :spouse #a/n[124]]
[#a/n[123] :child #a/n[125]]
[#a/n[124] :type :person]
[#a/n[124] :first-name "Barney"]
[#a/n[124] :last-name "Rubble"]
[#a/n[124] :spouse #a/n[123]]
[#a/n[124] :child #a/n[125]]
[#a/n[125] :type :person]
[#a/n[125] :first-name "Bam-Bam"]
[#a/n[125] :last-name "Rubble"]]
(require '[clojure.edn :as edn])
(def data (edn/read-string (slurp "triples.edn")))
(def tx @(d/transact conn {:tx-triples data}))