{"id":16659539,"url":"https://github.com/r0man/datumbazo","last_synced_at":"2025-03-15T12:30:32.800Z","repository":{"id":2121234,"uuid":"3063769","full_name":"r0man/datumbazo","owner":"r0man","description":"A JDBC driver for SQLingvo","archived":false,"fork":false,"pushed_at":"2024-05-07T20:15:24.000Z","size":1525,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T01:29:15.113Z","etag":null,"topics":["clojure","clojurescript","lisp","postgresql","sqlingvo"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r0man.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2011-12-28T16:50:45.000Z","updated_at":"2021-02-05T15:38:22.000Z","dependencies_parsed_at":"2024-11-27T19:17:03.883Z","dependency_job_id":null,"html_url":"https://github.com/r0man/datumbazo","commit_stats":{"total_commits":1388,"total_committers":7,"mean_commits":"198.28571428571428","dds":"0.45461095100864557","last_synced_commit":"1446bfc92fe07d72137782682da4c18669c66787"},"previous_names":[],"tags_count":135,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0man%2Fdatumbazo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0man%2Fdatumbazo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0man%2Fdatumbazo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0man%2Fdatumbazo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r0man","download_url":"https://codeload.github.com/r0man/datumbazo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243730865,"owners_count":20338729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["clojure","clojurescript","lisp","postgresql","sqlingvo"],"created_at":"2024-10-12T10:25:40.133Z","updated_at":"2025-03-15T12:30:32.425Z","avatar_url":"https://github.com/r0man.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"* Datumbazo\n\n  [[https://clojars.org/datumbazo][https://img.shields.io/clojars/v/datumbazo.svg]]\n  [[https://github.com/r0man/datumbazo/actions?query=workflow%3A%22Clojure+CI%22][https://github.com/r0man/datumbazo/workflows/Clojure%20CI/badge.svg]]\n  [[https://versions.deps.co/r0man/datumbazo][https://versions.deps.co/r0man/datumbazo/status.svg]]\n  [[https://versions.deps.co/r0man/datumbazo][https://versions.deps.co/r0man/datumbazo/downloads.svg]]\n\n  A Clojure [[https://www.oracle.com/technetwork/java/javase/jdbc/index.html][JDBC]] driver for [[https://github.com/r0man/sqlingvo][SQLingvo]].\n\n** Usage\n*** Imports\n\n    /Datumbazo/ shadows some functions from the =clojure.core=\n    namespace, such as =distinct=, =group-by= and =update=\n    functions. It's recommended to require the =datumbazo.core=\n    namespace via an alias, such as =sql=.\n\n    #+BEGIN_SRC clojure :exports code :results silent\n      (require '[datumbazo.core :as sql])\n    #+END_SRC\n\n*** Database component\n\n    You can make a new database [[https://github.com/stuartsierra/component][component]] from an URL with the\n    =db= function.\n\n    #+BEGIN_SRC clojure :exports both :results silent\n      (def db-spec (sql/db \"postgresql://tiger:scotch@localhost/datumbazo\"))\n    #+END_SRC\n\n    A database component can be started and stopped with the =start=\n    and =stop= functions from the [[https://github.com/stuartsierra/component][component]] library. The following\n    code opens a connection to the database and binds the updated\n    component to the =db= symbol.\n\n    #+BEGIN_SRC clojure :exports both :results silent\n      (require '[com.stuartsierra.component :as component])\n      (def db (component/start db-spec))\n    #+END_SRC\n\n*** Select\n\n    Select a simple expression. Note that the column names in the\n    result are generated by the database driver and are database\n    vendor specific.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/select db [1 2 3])\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:?column? 1, :?column?_2 2, :?column?_3 3})\n\n    Select the result of a function call.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/select db ['(- (now) (cast \"1 day\" :interval))])\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:?column? #inst \"2019-01-13T21:05:17.621-00:00\"})\n\n    Select columns from the =information_schema.tables= table.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/select db [:table_catalog :table_schema :table_name]\n         (sql/from :information_schema.tables)\n         (sql/where '(= :table_name \"pg_statistic\")))\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:table_catalog \"datumbazo\", :table_schema \"pg_catalog\", :table_name \"pg_statistic\"})\n\n*** Create table\n\n    Create a countries table with =name= and =code= columns.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/create-table db :countries\n         (sql/column :id :serial :primary-key? true)\n         (sql/column :name :text)\n         (sql/column :code :text))\n    #+END_SRC\n\n    #+RESULTS:\n    : [{:count 0}]\n\n*** Insert\n\n    Insert a row into the countries table and return the inserted rows.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/insert db :countries []\n         (sql/values [{:code \"de\" :name \"Germany\"}\n                      {:code \"es\" :name \"Spain\"}])\n         (sql/returning :*))\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:id 5, :name \"Germany\", :code \"de\"} {:id 6, :name \"Spain\", :code \"es\"})\n\n*** Order by\n\n    Select all countries ordered by the =name= column in ascending\n    order.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/select db [:*]\n         (sql/from :countries)\n         (sql/order-by (sql/asc :name)))\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:id 1, :name \"Germany\", :code \"de\"} {:id 3, :name \"Germany\", :code \"de\"} {:id 5, :name \"Germany\", :code \"de\"} {:id 2, :name \"Spain\", :code \"es\"} {:id 4, :name \"Spain\", :code \"es\"} {:id 6, :name \"Spain\", :code \"es\"})\n\n*** Where clauses\n\n    Select the =id= and =code= columns of the =countries= table for\n    all rows whose =name= columns is equal to =Spain=.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/select db [:id :code]\n         (sql/from :countries)\n         (sql/where '(= :name \"Spain\")))\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:id 2, :code \"es\"} {:id 4, :code \"es\"} {:id 6, :code \"es\"})\n\n*** Delete\n\n    Delete a country by name, and return the affected rows.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/delete db :countries\n         (sql/where '(= :name \"Spain\"))\n         (sql/returning :*))\n    #+END_SRC\n\n    #+RESULTS:\n    : ({:id 2, :name \"Spain\", :code \"es\"} {:id 4, :name \"Spain\", :code \"es\"} {:id 6, :name \"Spain\", :code \"es\"})\n\n*** Drop table\n\n    Drop the countries table.\n\n    #+BEGIN_SRC clojure :exports both :results verbatim\n      @(sql/drop-table db [:countries])\n    #+END_SRC\n\n    #+RESULTS:\n    : [{:count 0}]\n\n** License\n\n   Copyright © 2012-2019 [[https://github.com/r0man][r0man]]\n\n   Distributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0man%2Fdatumbazo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr0man%2Fdatumbazo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0man%2Fdatumbazo/lists"}