This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-23
Channels
- # announcements (7)
- # babashka (40)
- # babashka-sci-dev (74)
- # beginners (74)
- # calva (31)
- # cider (11)
- # clj-kondo (22)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (70)
- # clojure-brasil (3)
- # clojure-dev (12)
- # clojure-europe (39)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (2)
- # conjure (1)
- # core-async (3)
- # cursive (1)
- # data-science (1)
- # datalevin (13)
- # datomic (17)
- # emacs (42)
- # events (1)
- # fulcro (16)
- # graphql (9)
- # helix (1)
- # holy-lambda (14)
- # honeysql (2)
- # hugsql (3)
- # hyperfiddle (5)
- # kaocha (10)
- # lsp (41)
- # luminus (5)
- # malli (7)
- # meander (3)
- # membrane (47)
- # off-topic (23)
- # podcasts (2)
- # polylith (34)
- # rdf (4)
- # re-frame (2)
- # releases (2)
- # remote-jobs (1)
- # ring (16)
- # shadow-cljs (111)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (19)
Not sure how to work the api with a reference to db (instead of conn):
(d/with-conn [conn "/pbdb"]
(assert (d/db? (d/db conn)))
;(pp/pprint (d/stat conn))
;(d/copy (d/db conn) "/pbdb-backup")
;(d/copy conn "/pbdb-backup")
both the stat and copy functions seem to work on a "db" instance, but not sure how to concoct a db from a connection or a directory-path to the db-files...
Error message in stack trace not too helpful:
"No implementation of method: :copy of protocol: #'datalevin.lmdb/ILMDB found for class: datalevin.db.DB",
:at
[clojure.core$cacheprotocol_fn
invokeStatic
"core_deftype.clj"
583]}],I expect people to use dtlv command line tool to do database backup, so the API is not really designed for people to do this programmatically. It’s doable, but not as convenient as it could be.
actually, I will do better, I will release a version to allow datalog db to be copied programmatically easily, just like the code you tried.
Thanks! That would make integration easier. It’s a little confusing that datalevin has the concepts of those different dbs that all are build off the same db-files… and the docs do not really distinguish those. Most users will happily use datalevin without ever having to know about those details - guess I’m the lucky one ;-)
An easy programmatic way to copy the datalevin db would be nice. Also because using dtlv to do that while the datalevin java-runtime is still active in another process made me wonder if that could cause issues. (?)
it’s not a problem to copy a db file that is being used by another process. LMDB handles that correctly. Just copy away.
Ok… the following seems to work: (when-not data-mdb (d/with-conn [conn "/pbdb"] (let [dl-db (d/db conn) lmdb-db (.-lmdb (.-store dl-db))] (assert (d/db? dl-db)) (pp/pprint (d/stat lmdb-db)) (d/copy lmdb-db "/pbdb-backup") ))) Which yields a single data.mdb file in the newly created /pbdb-backup dir - so no lock.mdb file - is that expected?