Fork me on GitHub
Norman Kabir00:02:10

I'm scripting the creation of Datalevin database for testing. Is this the preferred method to create a new database with schema using dtlv?

$ dtlv exec << EOF
(def conn (get-conn "/tmp/test-db"))
(close conn)
With an associated update-schema call?


this should work

Norman Kabir16:02:01

The (help) for dtlv indicates:

Datalevin (version: 0.5.28)

  Type (help) to see available functions. Clojure core functions are also available.
  Type (exit) to exit.
user> (help)

In addition to Clojure core functions, the following functions are available:

In namespace datalevin.core
So clojure.core functions should be available. But
user> (load-file "demo.edn")
Could not resolve symbol: clojure.core/load-file


What is load-file, I don’t think datalevin has such a function


oh you mean clojure.core function


sorry, i should rephrase it, it’s not clojure.core, but rather the part of clojure.core functions that are implemented by sci


load-file doesn't come with SCI by default but it's fairly easy to implement


thx for letting us know. If people really need some functions, we can probably implement them, either in sci or datalevin.


sci only has "safe" functions by default, no functions that access the file system


babashka implements load-file just by slurping the file and then calling sci/eval-string on that, while binding sci/file to the filename


It makes sense.


@URMJAL866 I would like to see a use case where load-file is necessary for using Datalevin

Norman Kabir23:02:40

Hi @U0A74MRCJ I wanted to use dtlv to set up a database via a bash script:

dtlv exec << EOF 
(def c (get-conn "${DATABASE_DA:?}"))
(def schema ${schema:?})
(update-schema c schema)
(close c)
I wanted to load the schema from an edn file. As a workaround, I created a bash variable and assign it as above. Direct loading would be much nicer.

Norman Kabir11:02:28;cid=C01RD3AF336 @U04V15CAJ I read about this in the babashka docs but it's not clear to me which features are exposed within the dtlv interpreter:

Datalevin (version: 0.5.28)

  Type (help) to see available functions. Clojure core functions are also available.
  Type (exit) to exit.
user> (require 'sci/file)
Could not find namespace sci/file.
user> file
Could not resolve symbol: file


These things are not exposed in the interpreted scripts, but exposed in the interpreter API for creating script environments.

Norman Kabir02:02:27

So it is something that needs to be exposed via Datalevin rather than a script I would write independently?


0.5.29 was released yesterday. it includes a fix by @denik thanks!

👍 1

plan to release a new version soon for a few other fixes.


Please file issues in addition to discussing here, as I normally work through the issues when I get some time to work on Datalevin. Thanks!

Norman Kabir23:02:15

Congratulations! And, thank you!