datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
jacklombard 2021-01-11T03:34:39.224300Z

Apologies for the beginner question and for the cross post from the beginners channel (was asked to post here). I'm having trouble doing a basic query using the peer library, I have tried both the dev (with the dev transactor running) and mem protocols.

(comment
  (def db-uri "datomic:<mem://localhost:4334/indium%22|mem://localhost:4334/indium">)
  (def db-uri "datomic:<dev://localhost:4334/indium%22|dev://localhost:4334/indium">)
  (d/create-database db-uri)
  (def conn (d/connect db-uri))
  (def db (d/db conn))
  (def movie-schema [{:db/ident       :movie/title
                      :db/valueType   :db.type/string
                      :db/cardinality :db.cardinality/one
                      :db/doc         "The title of the movie"}
                     {:db/ident       :movie/genre
                      :db/valueType   :db.type/string
                      :db/cardinality :db.cardinality/one
                      :db/doc         "The genre of the movie"}
                     {:db/ident       :movie/release-year
                      :db/valueType   :db.type/long
                      :db/cardinality :db.cardinality/one
                      :db/doc         "The year the movie was released in theaters"}])
  (def first-movies [{:movie/title        "Explorers"
                      :movie/genre        "adventure/comedy/family"
                      :movie/release-year 1985}
                     {:movie/title        "Demolition Man"
                      :movie/genre        "action/sci-fi/thriller"
                      :movie/release-year 1993}
                     {:movie/title        "Johnny Mnemonic"
                      :movie/genre        "cyber-punk/action"
                      :movie/release-year 1995}
                     {:movie/title        "Toy Story"
                      :movie/genre        "animation/adventure"
                      :movie/release-year 1995}])
  (d/transact conn movie-schema)
  (d/transact conn first-movies)
  (def all-movies-q '[:find ?e
                      :where [?m :movie/title ?e]])
  (d/q all-movies-q db))
This is the error when I run (d/q all-movies-q db)
Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:79).
:db.error/not-an-entity Unable to resolve entity: :movie/title

jacklombard 2021-01-11T03:35:32.225300Z

Tried derefing the both the movie-schema and first-movies transactions so that it waits for it to (complete?), still the same error. Guessing the movie schema is not being persisted?

2021-01-11T08:39:36.227Z

You also get a db-after value from d/transact !

jcf 2021-01-11T11:28:28.229500Z

Best practice is to use the :db-after from your transact call. https://docs.datomic.com/on-prem/best-practices.html#use-dbafter

cjmurphy 2021-01-11T03:47:21.226100Z

The db you are using stale. After doing any transacts a new db needs to be grabbed.

✔️ 1
oxalorg (Mitesh) 2021-01-11T06:42:38.226300Z

^^ Doing something like this: (defn db [] (d/db conn)) and then replacing calls to db with (db) should solve this

PB 2021-01-11T16:38:17.231700Z

I have my datomic transactor running from within a docker container. Upon upgrading to 0.9.6024 I am getting the following error:

Execution error (JdbcSQLException) at org.h2.engine.SessionRemote/done (SessionRemote.java:568).
Remote connections to this server are not allowed, see -tcpAllowOthers [90117-171]
I cannot find much about this. Can anybody give me any hints?

favila 2021-01-11T16:52:57.232200Z

(that’s a really old datomic you’re upgrading from if this is indeed your issue…)

favila 2021-01-11T16:54:07.232500Z

basically if you want to connect to free or dev over tcp, you now need to set a password.

PB 2021-01-11T17:45:00.232700Z

Thank you @favila

JAtkins 2021-01-11T21:57:53.233600Z

Is there a way to retrieve a datomic ion build id (git sha) from the running env?

JAtkins 2021-01-12T19:02:33.242100Z

Dunno if this works for you, but I added a job in my build script for ion push that writes the current sha into the resources folder before packing into the jar.

tatut 2021-01-13T05:05:14.248700Z

I did the same, but then you can’t use :rev but have to have :uname instead

tatut 2021-01-13T05:05:19.248900Z

as the git tree isn’t clean

JAtkins 2021-01-13T15:46:21.252700Z

Wouldn't it be? Ions can only push from clean git trees*, and if you ignore the build repos nothing should change anyway. I used git rev-parse HEAD