{"id":28352630,"url":"https://github.com/babashka/babashka-sql-pods","last_synced_at":"2026-01-12T02:04:50.938Z","repository":{"id":42002325,"uuid":"261980534","full_name":"babashka/babashka-sql-pods","owner":"babashka","description":"Babashka pods for SQL databases","archived":false,"fork":false,"pushed_at":"2025-09-11T15:24:22.000Z","size":170,"stargazers_count":91,"open_issues_count":11,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-11T18:33:07.593Z","etag":null,"topics":["babashka","clojure","hsqldb","jdbc","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babashka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-07T07:29:23.000Z","updated_at":"2025-09-11T15:24:23.000Z","dependencies_parsed_at":"2024-06-19T09:40:40.097Z","dependency_job_id":"5068628f-9db8-462a-8e95-cb2d09a0899c","html_url":"https://github.com/babashka/babashka-sql-pods","commit_stats":null,"previous_names":["borkdude/pod-babashka-hsqldb"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/babashka/babashka-sql-pods","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fbabashka-sql-pods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fbabashka-sql-pods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fbabashka-sql-pods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fbabashka-sql-pods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babashka","download_url":"https://codeload.github.com/babashka/babashka-sql-pods/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fbabashka-sql-pods/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babashka","clojure","hsqldb","jdbc","postgresql"],"created_at":"2025-05-28T00:07:15.327Z","updated_at":"2026-01-12T02:04:50.928Z","avatar_url":"https://github.com/babashka.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Babashka sql pods\n\n[Babashka](https://github.com/borkdude/babashka) pods for interacting with SQL\ndatabases.\n\nSupported databases:\n\n- [HSQLDB](http://www.hsqldb.org/)\n- [Microsoft SQL Server](https://www.microsoft.com/nl-nl/sql-server)\n- [MySQL](https://www.mysql.com)\n- [Oracle](https://www.oracle.com/database/)\n- [PostgresQL](https://www.postgresql.org/)\n\nPRs for other SQL databases are welcome. (Look at #15 + #20 for an example of adding a new DB.)\n\n## Install\n\nThe following installation methods are available:\n\n- Use the latest version from the\n  [pod-registry](https://github.com/babashka/pod-registry). This is done by\n  calling `load-pod` with a qualified keyword:\n\n  ``` clojure\n  (require '[babashka.pods :as pods])\n  (pods/load-pod 'org.babashka/postgresql \"0.1.0\")\n  ```\n\n  Babashka will automatically download the pod if it is not available on your system yet.\n\n- Download a binary from Github releases\n\u003c!-- - With [brew](https://brew.sh/): `brew install borkdude/brew/pod-babashka-\u003cdb\u003e` --\u003e\n\u003c!-- where `\u003cdb\u003e` must be substited with the database type, either `hsqldb` or --\u003e\n\u003c!-- `postgresql`. --\u003e\n\n## Compatibility\n\nPods from this repo require babashka v0.4.3 or later.\n\n## Available vars\n\nThe pods expose these namespaces with vars, where `\u003cdb\u003e` must be substituted with\nthe database type, either `hsqldb`, `postgresql`, or `oracle`:\n\n- `pod.babashka.\u003cdb\u003e`:\n  - `execute!`: similar to `next.jdbc/execute!`\n  - `execute-one!`: similar to `next.jdbc/execute-one!`\n  - `get-connection`: returns connection serialized using maps with a unique identifier key\n  - `close-connection`: closes a connection returned from `get-connection`\n  - `with-transaction`: similar to `next.jdbc/with-transaction`\n- `pod.babashka.\u003cdb\u003e.sql`:\n  - `insert-multi!`: similar to `next.jdbc.sql/insert-multi!`\n- `pod.babashka.\u003cdb\u003e.transaction`:\n  - `begin`: marks the begin of a transaction, expects connection returned from `get-connection`\n  - `rollback`: rolls back transaction, expects connection returned from `get-connection`\n  - `commit`: commits transaction, expects connection returned from `get-connection`\n\nMore functions from [next.jdbc](https://github.com/seancorfield/next-jdbc) can\nbe added. PRs welcome.\n\n## Run\n\nAn example using `pod-babashka-postgresql`:\n\n``` clojure\n(require '[babashka.pods :as pods])\n\n;; load from pod registry:\n(pods/load-pod 'org.babashka/postgresql \"0.1.0\")\n;; or load from system path:\n;; (pods/load-pod \"pod-babashka-postgresql\")\n;; or load from a relative or absolute path:\n;; (pods/load-pod \"./pod-babashka-postgresql\")\n\n(require '[pod.babashka.postgresql :as pg])\n\n(def db {:dbtype   \"postgresql\"\n         :host     \"your-db-host-name\"\n         :dbname   \"your-db\"\n         :user     \"develop\"\n         :password \"develop\"\n         :port     5432})\n\n(pg/execute! db [\"select version()\"])\n;;=\u003e [{:version \"PostgreSQL 9.5.18 on x86_64-pc-linux-gnu (Debian 9.5.18-1.pgdg90+1), compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit\"}]\n```\n\nAn example using `pod-babashka-hsqldb`:\n\n``` clojure\n(require '[babashka.pods :as pods])\n\n;; load from pod registry:\n(pods/load-pod 'org.babashka/hsqldb \"0.1.0\")\n;; or load from system path:\n;; (pods/load-pod \"pod-babashka-hsqldb\")\n;; or load from a relative or absolute path:\n;; (pods/load-pod \"./pod-babashka-hsqldb\")\n\n(require '[pod.babashka.hsqldb :as db])\n\n(def db \"jdbc:hsqldb:mem:testdb;sql.syntax_mys=true\")\n(db/execute! db [\"create table foo ( foo int );\"])\n;;=\u003e [#:next.jdbc{:update-count 0}]\n\n(db/execute! db [\"create table foo ( foo int );\"])\n;;=\u003e ... error output from pod omitted\n;;=\u003e clojure.lang.ExceptionInfo: object name already exists: FOO in statement [create table foo ( foo int )] [at line 6, column 1]\n\n(db/execute! db [\"insert into foo values (1, 2, 3);\"])\n;;=\u003e [#:next.jdbc{:update-count 3}]\n\n(db/execute! db [\"select * from foo;\"])\n;;=\u003e [#:FOO{:FOO 1} #:FOO{:FOO 2} #:FOO{:FOO 3}]\n```\n\nA more elaborate example can be found\n[here](https://github.com/borkdude/babashka/blob/2d12c954a1ef25e6ed83cde3db57be69dbb0c906/examples/hsqldb_unused_vars.clj).\n\n### Arrays\n\n#### Writing arrays\n\nInserting arrays works automatically: just pass a Java array, with e.g. `(into-array [1 2 3])`.\n\n#### Reading arrays\n\nArray columns automatically get converted to Clojure vectors. Converting back\ninto arrays must be done manually.\n\n### JSON\n\nThis section only applies to PostgreSQL for now, but can be extended to other databases.\n\n#### Writing JSON\n\n- Convert to a JSON string manually and insert with `?::text`. PostgreSQL will automatically convert the parameter to the right type. Full example:\n\n``` clojure\n(db/execute! db [\"insert into json_table values (?::text);\" (json/generate-string {:a 1})])\n```\n\n- Use `db/write-json` or `db/write-jsonb`. Full example:\n\n``` clojure\n(db/execute! db [\"insert into json_table values (?);\" (db/write-json {:a 1})])\n```\n\n#### Reading JSON\n\n- Both json and jsonb are automatically converted to Clojure values. Keys are keywordized automatically. You can override this behavior by passing a `:pod.babashka.sql/read` option to `execute!`:\n\n``` clojure\n{:pod.babashka.sql/read {:json :parse+keywordize}} ;; default\n{:pod.babashka.sql/read {:json :parse}} ;; no keyword keys\n{:pod.babashka.sql/read {:json :string}} ;; json as raw string\n```\n\nUse `:jsonb` to apply these options to jsonb-typed columns.\n\n- Select column as text and deserialize the result manually:\n\n``` clojure\n(db/execute! db [\"select json::text from json_table;\"])\n```\n\n## Libraries\n\nIn addition to using a sql pod, the following babashka-compatible libraries might be\nhelpful:\n\n### [honeysql](https://github.com/seancorfield/honeysql)\n\nTurn Clojure data structures into SQL.\n\nNeeds babashka \u003e= 0.2.6. Babashka is tested against HoneySQL version `2.2.861` in CI.\n\nExample:\n\n``` clojure\n(ns honeysql-script\n  (:require [babashka.deps :as deps]\n            [babashka.pods :as pods]))\n\n;; Load HoneySQL from Clojars:\n(deps/add-deps '{:deps {com.github.seancorfield/honeysql {:mvn/version \"2.2.861\"}}})\n\n(require '[honey.sql :as hsql])\n\n(hsql/format {:select [:a :b :c] :from [:foo] :where [:= :a 1]})\n;;=\u003e [\"SELECT a, b, c FROM foo WHERE a = ?\" 1]\n```\n\n## Troubleshooting\n\n### MS SQL Server support\n\nIf you are connecting to SQL Server, you may try connecting like this:\n\n```clojure\n(require '[pod.babashka.mssql :as sql])\n(def db {:dbtype \"mssql\" :host \"my-dbhost\" :dbname \"my_db\" :integratedSecurity true})\n(sql/execute! db ...)\n```\n\nUsing integrated security like this will not work (yet?) - you will get an error:\n\n```\n----- Error --------------------------------------------------------------------\nType:     clojure.lang.ExceptionInfo\nMessage:  This driver is not configured for integrated authentication. ClientConnectionId:889ad681-4fdf-409c-b12c-9eef93129023\n```\n\nAs a workaround, you can use [this pod](https://github.com/xledger/pod_sql_server), which connects via a .NET library.\n\nIf you are using SQL Server, you may also be interested in [this pod](https://github.com/xledger/pod_tsql_scriptdom), which has a function to reformat/indent your SQL.\n\n## Dev\n\nSet `POD_DB_TYPE` to either `hsqldb`, `postgresql`, or `oracle`.\n\n### Build\n\nRun `bb script/compile.clj`\n\n### Test\n\nRun `script/test`.\n\n### Reflection configs\n\nSee https://www.graalvm.org/native-image/libraries-and-frameworks\nAlso projects like Micronaut, Helidon, might help obtaining the right configs.\n\n## License\n\nCopyright © 2020-2021 Michiel Borkent\n\nDistributed under the EPL License. See LICENSE.\n\n[Helidon license](https://github.com/oracle/helidon/blob/master/LICENSE.txt)\n[HyperSQL license](http://hsqldb.org/web/hsqlLicense.html)\n[MySQL JDBC license](https://downloads.mysql.com/docs/licenses/connector-j-8.0-gpl-en.pdf)\n[MSSQL JDBC license](https://raw.githubusercontent.com/microsoft/mssql-jdbc/dev/LICENSE)\n[PostgreSQL JDBC license](https://jdbc.postgresql.org/about/license.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fbabashka-sql-pods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabashka%2Fbabashka-sql-pods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fbabashka-sql-pods/lists"}