Fork me on GitHub
#sql
<
2022-10-07
>
Søren Sjørup09:10:02

Not sure what channel to put this is, apologies if this not the one. One thing I really like about Datomic and it’s derivatives is that one can use multiple fact sources in queries. And also that one can use both databases and collections of facts as sources. What I’ve been thinking would also be nice is using SQL databases as sources. I imagine one could query them in a similar way where the entity position is the rowid and the attribute is :table-name/column-name . So an example from Datomics documentation would be:

[:find ?release-name
 :in $ ?artist-name
 :where [?artist-rowid :artist/name ?artist-name]
        [?release-rowid :release/artists ?artist-rowid]
        [?release-rowid :release/name ?release-name]]
Do any of you know of a library that does something like this? Or do you think it’s interesting?

seancorfield17:10:17

Maybe some of these would be interesting? https://clojurelog.github.io/ I don't know if there are any specific Datalog-to-SQL libraries. SEQL is a halfway house that lets you write declarative queries using EDN so that might also interest you (see the Friendly SQL Functions page in the next.jdbc docs for links to that and other DSL libraries).

Søren Sjørup18:10:13

Thank you for those pointers! I will try and look into if one can extend datascript to take sources that are JDBC-connections.