diff --git a/README.md b/README.md index 3704f31..43a5e41 100644 --- a/README.md +++ b/README.md @@ -12,54 +12,55 @@ Here the instructions on how to build your own Clojure projects with GraalVM. Here the list of libraries tested: -| Status | Library | Description | Remarks | -|:------------------:|------------------------------------------------------|---------------------------------------------------------------------|--------------------------------| -| :white_check_mark: | [Clojure core](./clojure) | Clojure core | | -| :white_check_mark: | [clojure spec](./spec) | Clojure Spec | | -| :white_check_mark: | [clojure/tools.logging](./tools-logging) | Logging library | | -| :white_check_mark: | [clojure/tools.logging+log4j](./tools-logging-log4j) | Logging library | | -| :white_check_mark: | [aleph](./aleph) | Web server | | -| :white_check_mark: | [amazonica+s3](./amazonica-s3) | Cloud API wrapper library | | -| :white_check_mark: | [asami](./asami) | Asami DB | | -| :white_check_mark: | [aws-api+s3](./aws-api-s3) | Cognitect AWS client library | | -| :white_check_mark: | [buffy](./buffy) | Buffy, The Byte Buffer Slayer | | -| :white_check_mark: | [carmine](./carmine) | Redis client and message queue for Clojure | | -| :white_check_mark: | [cheshire](./cheshire) | JSON parser/writer | | -| :white_check_mark: | [cli4clj](./cli4clj) | Interactive Command Line Interfaces (CLIs) for Clojure Applications | | -| :white_check_mark: | [cljfmt](./cljfmt) | Source Formatter | | -| :white_check_mark: | [clj-http-lite](./clj-http-lite) | Web client | | -| :x: | [clj-sophia](./clj-sophia) | A fast RAM-Disk hybrid storage | *Runtime error/JNA* | -| :white_check_mark: | [clj-uuid](./clj-uuid) | RFC4122 Unique Identifiers for Clojure | No objects in namespaced uuids | -| :white_check_mark: | [clara-rules](./clara-rules) | A Clojure forward-chaining rules engine | *Using AOT compiled session* | -| :white_check_mark: | [clostache](./clostache) | {{ mustache }} for Clojure | | -| :white_check_mark: | [component](./component) | Managing lifecycle and dependencies of software | | -| :white_check_mark: | [cprop](./cprop) | Configuration/property management | | -| :white_check_mark: | [datascript](./datascript) | Immutable database and Datalog query engine | | -| :warning: | [fastmath](./fastmath) | Fast and primitive math and stats library | *See README* | -| :white_check_mark: | [fire](./fire) | A lightweight clojure client for Firebase based using the REST API. | | -| :white_check_mark: | [hiccup](./hiccup) | Fast library for rendering HTML in Clojure | | -| :white_check_mark: | [http-kit](./http-kit) | Web server and server | | -| :white_check_mark: | [integrant](./integrant) | Alternative to mount, component etc. | | -| :white_check_mark: | [lacinia](./lacinia) | A GraphQL server implementation in pure Clojure | | -| :white_check_mark: | [loom](./loom) | A Graph manipulation and computation library. | | -| :x: | [monger](./monger) | An idiomatic Clojure MongoDB driver with sane defaults | | -| :white_check_mark: | [μ/log](./mulog) | Event logging system | | -| :white_check_mark: | [next.jdbc + honeysql](./next-jdbc) | Database driver and SQL-in-Clojure | | -| :white_check_mark: | [nippy](./nippy) | Clojure serialization/deserialization library | | -| :white_check_mark: | [pp-grid](./pp-grid) | A text-formatting library | | -| :white_check_mark: | [ring/jetty](./ring-jetty) | Web server | | -| :white_check_mark: | [RoaringBitmap](./roaring) | Bitset library | | -| :white_check_mark: | [safely](./safely) | Circuit breaker | | -| :white_check_mark: | [secure-random](./secure-random) | `SecureRandom` initialization | | -| :white_check_mark: | [selmer](./selmer) | A fast, Django inspired template system for Clojure. | | -| :white_check_mark: | [system](./system) | Layer on top of components | | -| :white_check_mark: | [tech.ml.dataset](./tech.ml.dataset) | A Clojure high performance data processing system | | -| :white_check_mark: | [timbre](./timbre) | Pure Clojure/Script logging library | | -| :white_check_mark: | [pedestal](./pedestal) | Pedestal is a sturdy and reliable base for services and APIs. | requires reflect-config.json | -| :white_check_mark: | [claypoole](./claypoole) | Claypoole: Threadpool tools for Clojure | | -| :white_check_mark: | [upit](./upit) | Very very simple library to initialise your app stack. | | -| :white_check_mark: | [zetasketch](./zetasketch) | Sketch data structures like HLL | requires reflect-config.json | -| :white_check_mark: | [pg2-core](./pg2-core) | A Fast PostgreSQL Driver For Clojure | | +| Status | Library | Description | Remarks | +|:------------------:|------------------------------------------------------|---------------------------------------------------------------------------------------------------|--------------------------------| +| :white_check_mark: | [Clojure core](./clojure) | Clojure core | | +| :white_check_mark: | [clojure spec](./spec) | Clojure Spec | | +| :white_check_mark: | [clojure/tools.logging](./tools-logging) | Logging library | | +| :white_check_mark: | [clojure/tools.logging+log4j](./tools-logging-log4j) | Logging library | | +| :white_check_mark: | [aleph](./aleph) | Web server | | +| :white_check_mark: | [amazonica+s3](./amazonica-s3) | Cloud API wrapper library | | +| :white_check_mark: | [asami](./asami) | Asami DB | | +| :white_check_mark: | [aws-api+s3](./aws-api-s3) | Cognitect AWS client library | | +| :white_check_mark: | [buffy](./buffy) | Buffy, The Byte Buffer Slayer | | +| :white_check_mark: | [carmine](./carmine) | Redis client and message queue for Clojure | | +| :white_check_mark: | [cheshire](./cheshire) | JSON parser/writer | | +| :white_check_mark: | [cli4clj](./cli4clj) | Interactive Command Line Interfaces (CLIs) for Clojure Applications | | +| :white_check_mark: | [cljfmt](./cljfmt) | Source Formatter | | +| :white_check_mark: | [clj-http-lite](./clj-http-lite) | Web client | | +| :x: | [clj-sophia](./clj-sophia) | A fast RAM-Disk hybrid storage | *Runtime error/JNA* | +| :white_check_mark: | [clj-uuid](./clj-uuid) | RFC4122 Unique Identifiers for Clojure | No objects in namespaced uuids | +| :white_check_mark: | [clara-rules](./clara-rules) | A Clojure forward-chaining rules engine | *Using AOT compiled session* | +| :white_check_mark: | [clostache](./clostache) | {{ mustache }} for Clojure | | +| :white_check_mark: | [component](./component) | Managing lifecycle and dependencies of software | | +| :white_check_mark: | [cprop](./cprop) | Configuration/property management | | +| :white_check_mark: | [datascript](./datascript) | Immutable database and Datalog query engine | | +| :warning: | [fastmath](./fastmath) | Fast and primitive math and stats library | *See README* | +| :white_check_mark: | [fire](./fire) | A lightweight clojure client for Firebase based using the REST API. | | +| :white_check_mark: | [hiccup](./hiccup) | Fast library for rendering HTML in Clojure | | +| :white_check_mark: | [http-kit](./http-kit) | Web server and server | | +| :white_check_mark: | [integrant](./integrant) | Alternative to mount, component etc. | | +| :white_check_mark: | [lacinia](./lacinia) | A GraphQL server implementation in pure Clojure | | +| :white_check_mark: | [loom](./loom) | A Graph manipulation and computation library. | | +| :x: | [monger](./monger) | An idiomatic Clojure MongoDB driver with sane defaults | | +| :white_check_mark: | [μ/log](./mulog) | Event logging system | | +| :white_check_mark: | [next.jdbc + honeysql](./next-jdbc) | Database driver and SQL-in-Clojure | | +| :white_check_mark: | [nippy](./nippy) | Clojure serialization/deserialization library | | +| :white_check_mark: | [pp-grid](./pp-grid) | A text-formatting library | | +| :white_check_mark: | [ring/jetty](./ring-jetty) | Web server | | +| :white_check_mark: | [RoaringBitmap](./roaring) | Bitset library | | +| :white_check_mark: | [safely](./safely) | Circuit breaker | | +| :white_check_mark: | [secure-random](./secure-random) | `SecureRandom` initialization | | +| :white_check_mark: | [selmer](./selmer) | A fast, Django inspired template system for Clojure. | | +| :white_check_mark: | [system](./system) | Layer on top of components | | +| :white_check_mark: | [tech.ml.dataset](./tech.ml.dataset) | A Clojure high performance data processing system | | +| :white_check_mark: | [timbre](./timbre) | Pure Clojure/Script logging library | | +| :white_check_mark: | [pedestal](./pedestal) | Pedestal is a sturdy and reliable base for services and APIs. | requires reflect-config.json | +| :white_check_mark: | [claypoole](./claypoole) | Claypoole: Threadpool tools for Clojure | | +| :white_check_mark: | [upit](./upit) | Very very simple library to initialise your app stack. | | +| :white_check_mark: | [zetasketch](./zetasketch) | Sketch data structures like HLL | requires reflect-config.json | +| :white_check_mark: | [pg2-core](./pg2-core) | A Fast PostgreSQL Driver For Clojure | | +| :white_check_mark: | [next.jdbc + SQLite Driver](./sqlite) | A modern low-level Clojure wrapper for JDBC-based access to databases combined with SQLite Driver | | More libraries to come (*PRs are welcome*). diff --git a/sqlite/.gitignore b/sqlite/.gitignore new file mode 100644 index 0000000..9171df2 --- /dev/null +++ b/sqlite/.gitignore @@ -0,0 +1,16 @@ +/target +/classes +/checkouts +profiles.clj +pom.xml +pom.xml.asc +*.jar +*.class +/.lein-* +/.nrepl-port +.hgignore +.hg/ +/.idea/ +/sample-project.iml +/sqlite.iml +/.my-test.db diff --git a/sqlite/README.md b/sqlite/README.md new file mode 100644 index 0000000..4d9f598 --- /dev/null +++ b/sqlite/README.md @@ -0,0 +1,26 @@ +# next.jdbc + SQLite Driver + +Testing +whether [next.jdbc](https://github.com/seancorfield/next-jdbc) + [SQLite driver](https://github.com/xerial/sqlite-jdbc) +can be used in a native binary image with GraalVM(23). + +The source code for this example was based on: https://github.com/ericdallo/sqlite-graalvm-sample + +## Usage + +Currently testing: + + [org.xerial/sqlite-jdbc "3.41.2.1"] + [com.github.seancorfield/next.jdbc "1.3.955"] + +Test with (requires a local GraalVM installation): + + lein do clean, uberjar, native, run-native + +## Results + + [clojure.java.io :as io] :white_check_mark: + + [next.jdbc :as jdbc] :white_check_mark: + + [next.jdbc.result-set :as rs] :white_check_mark: diff --git a/sqlite/project.clj b/sqlite/project.clj new file mode 100644 index 0000000..936c328 --- /dev/null +++ b/sqlite/project.clj @@ -0,0 +1,29 @@ +(defproject sqlite "0.1.0-SNAPSHOT" + + :dependencies [[org.clojure/clojure "1.12.0"] + [org.xerial/sqlite-jdbc "3.41.2.1"] + [com.github.seancorfield/next.jdbc "1.3.955"] + [com.github.clj-easy/graal-build-time "1.0.5"]] + + :main sqlite.main + + :uberjar-name "sqlite.jar" + + :profiles {:uberjar {:aot :all} + :dev {:plugins [[lein-shell "0.5.0"]]}} + + :aliases + {"native" + ["shell" + "native-image" + "-Ob" + "-H:+TraceNativeToolUsage" + "-H:+AllowIncompleteClasspath" + "--verbose" + "--no-fallback" + "--report-unsupported-elements-at-runtime" + "--features=clj_easy.graal_build_time.InitClojureClasses" + "-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}" + "-H:Name=./target/${:name}"] + + "run-native" ["shell" "./target/${:name}"]}) diff --git a/sqlite/src/sqlite/main.clj b/sqlite/src/sqlite/main.clj new file mode 100644 index 0000000..618a2d7 --- /dev/null +++ b/sqlite/src/sqlite/main.clj @@ -0,0 +1,40 @@ +(ns sqlite.main + (:gen-class) + (:require [clojure.java.io :as io] + [next.jdbc :as jdbc] + [next.jdbc.result-set :as rs])) + +(defn make-spec [] + (let [lsp-db (io/file ".my-test.db")] + {:dbtype "sqlite" + :dbname (.getAbsolutePath lsp-db)})) + +(defn insert [] + (println "Inserting...") + (let [db-spec (make-spec)] + (io/make-parents (:dbname db-spec)) + (with-open [conn (jdbc/get-connection db-spec)] + (jdbc/execute! conn ["drop table if exists project;"]) + (jdbc/execute! conn ["create table project (version text, root text unique, hash text, classpath text, analysis text);"]) + (jdbc/execute! conn ["insert or replace into project + (version, root, hash, classpath, analysis) + values (?,?,?,?,?);" "1" "some-project" "some-hash" "some-classpath" "a lot of analysis"])))) + +(defn select [] + (println "Selecting...") + (try + (with-open [conn (jdbc/get-connection (make-spec))] + (let [project-row (-> (jdbc/execute! conn + ["select root, hash, classpath, analysis from project where version = ?" + "1"] + {:builder-fn rs/as-unqualified-lower-maps}) + (nth 0))] + (println "Success: " project-row))) + (catch Throwable e + (println "Could not load db" (.getMessage e))))) + + +(defn -main [] + (println "Hello GraalVM.") + (insert) + (select))