From 00ff409d11f7f888f4d5416e6e2e0fb05cde8724 Mon Sep 17 00:00:00 2001 From: Laurence Chen Date: Thu, 4 May 2023 22:16:41 +0800 Subject: [PATCH] to complete duckdb example --- examples/mbrainz-duckdb/README.md | 24 ++++--------------- examples/mbrainz-duckdb/deps.edn | 2 +- .../src/lambdaisland/mbrainz.clj | 4 ++-- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/examples/mbrainz-duckdb/README.md b/examples/mbrainz-duckdb/README.md index 12c9c25..f4a633a 100644 --- a/examples/mbrainz-duckdb/README.md +++ b/examples/mbrainz-duckdb/README.md @@ -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 @@ -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) -``` diff --git a/examples/mbrainz-duckdb/deps.edn b/examples/mbrainz-duckdb/deps.edn index 2e6b11a..6a82738 100644 --- a/examples/mbrainz-duckdb/deps.edn +++ b/examples/mbrainz-duckdb/deps.edn @@ -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"}} diff --git a/examples/mbrainz-duckdb/src/lambdaisland/mbrainz.clj b/examples/mbrainz-duckdb/src/lambdaisland/mbrainz.clj index 21b7675..ec88b4f 100644 --- a/examples/mbrainz-duckdb/src/lambdaisland/mbrainz.clj +++ b/examples/mbrainz-duckdb/src/lambdaisland/mbrainz.clj @@ -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 {} @@ -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)))