Skip to content

Commit

Permalink
to complete duckdb example
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Chen committed May 4, 2023
1 parent 0f36b71 commit 00ff409
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
24 changes: 5 additions & 19 deletions examples/mbrainz-duckdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This example demonstrates how mbrainz datomic database works with the
plenish. To use this example, we need to prepare the Datomic database
and the empty Postgres database.
and the empty duckDB database.

## Prepare the Datomic database
### Getting Datomic
Expand Down Expand Up @@ -38,29 +38,15 @@ From the `datomic-pro-$VERSION` directory, [restore the backup](http://docs.dato
## Prepare the empty duckdb database

1. Install duckdb CLI. Homebrew: `brew install duckdb`
2. rm /tmp/mbrainz

## Init the nREPL
## Init the nREPL with Debug flag

```
clj -M:dev:cider:postgresql:datomic-pro
export PLENISH_DEBUG=true && clj -M:dev:cider:duckdb:datomic-pro
```

## Results

After running the commands in `src/lambdaisland/mbrainz.clj`, the tables in Postgres db are
After running the commands in `src/lambdaisland/mbrainz.clj`, the tables in duckDB are

```
mbrainz# \d
List of relations
Schema │ Name │ Type │ Owner
────────┼────────────────────┼───────┼─────────
public │ artist │ table │ plenish
public │ idents │ table │ plenish
public │ idents_x_partition │ table │ plenish
public │ release │ table │ plenish
public │ release_x_artists │ table │ plenish
public │ release_x_labels │ table │ plenish
public │ release_x_media │ table │ plenish
public │ transactions │ table │ plenish
(8 rows)
```
2 changes: 1 addition & 1 deletion examples/mbrainz-duckdb/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
com.cnuernber/charred {:mvn/version "1.028"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.874"}
com.github.seancorfield/honeysql {:mvn/version "2.4.1026"}
com.lambdaisland/plenish {:mvn/version "0.4.50"}}
com.lambdaisland/plenish {:local/root "../../" }}

:mvn/repos
{"my.datomic.com" {:url "https://my.datomic.com/repo"}}
Expand Down
4 changes: 2 additions & 2 deletions examples/mbrainz-duckdb/src/lambdaisland/mbrainz.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[next.jdbc.result-set :as rs]))

(def datomic-conn (d/connect "datomic:dev://localhost:4334/mbrainz-1968-1973"))
(def pg-conn (jdbc/get-datasource "jdbc:pgsql://localhost:5432/mbrainz?user=plenish&password=plenish"))
(def duck-conn (jdbc/get-datasource "jdbc:duckdb:/tmp/mbrainz"))

(def metaschema
{:tables {:release/name {}
Expand All @@ -15,5 +15,5 @@
(def initial-ctx (plenish/initial-ctx datomic-conn metaschema))

(def new-ctx (plenish/import-tx-range
initial-ctx datomic-conn pg-conn
initial-ctx datomic-conn duck-conn
(d/tx-range (d/log datomic-conn) nil nil)))

0 comments on commit 00ff409

Please sign in to comment.