Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a persisting local datomic database?

Tags:

With Datomic, I am confused as to how to get a local database to play around with

If I type:

>>(ns datomic-tut (:use [datomic.api :as d]))
nil

>>(d/create-database "datomic:mem://hello")
true

>> (d/connect "datomic:mem://hello")
#<LocalConnection datomic.peer.LocalConnection@57102fab>

>> Ctrl-D to Disconnect

Then, if I restart the repl:

>> (ns project-ns   (:use [datomic.api :as d]))
nil

>> (d/connect "datomic:mem://hello")
ExceptionInfo :peer/db-not-found Could not find hello in catalog  clojure.core/ex-info (core.clj:4227)

Is there another type of local uri I can create that saves the database that I create?

like image 979
zcaudate Avatar asked Jun 12 '12 18:06

zcaudate


1 Answers

The getting started guide talks about using free storage protocol

Running the transactor with the free storage protocol

The free storage protocol uses local disk files for storage.

You can start a local transactor with free storage as follows:

bin/transactor config/samples/free-transactor-template.properties

This script will print a few lines of output, including the base URI you will use to connect, e.g.

datomic:free://localhost:4334/<DB-NAME>

To create a connection string, simply replace with a database name of your choice, e.g. "hello":

datomic:free://localhost:4334/hello

Using this URI, you should now be able to repeat the steps from the previous section, this time making your connection to the transactor.

like image 111
sw1nn Avatar answered Sep 21 '22 13:09

sw1nn