All Projects → duanebester → clunk

duanebester / clunk

Licence: other
Clojure Postgres w/out JDBC

Programming Languages

clojure
4091 projects

Labels

Projects that are alternatives of or similar to clunk

Chameleon
Customizable honeypots for monitoring network traffic, bots activities and username\password credentials (DNS, HTTP Proxy, HTTP, HTTPS, SSH, POP3, IMAP, STMP, RDP, VNC, SMB, SOCKS5, Redis, TELNET, Postgres and MySQL)
Stars: ✭ 230 (+820%)
Mutual labels:  postgres
Pg similarity
set of functions and operators for executing similarity queries
Stars: ✭ 250 (+900%)
Mutual labels:  postgres
event bus postgres
🐘 Postgres event store for event_bus
Stars: ✭ 49 (+96%)
Mutual labels:  postgres
Opencollective Api
Open Collective's API. A GraphQL API powered by Sequelize and PostgreSQL.
Stars: ✭ 233 (+832%)
Mutual labels:  postgres
Scenic
Scenic is maintained by Derek Prior, Caleb Hearth, and you, our contributors.
Stars: ✭ 2,856 (+11324%)
Mutual labels:  postgres
Pg Extend Rs
Postgres extension library for Rust
Stars: ✭ 253 (+912%)
Mutual labels:  postgres
Activerecord Postgres enum
Integrate PostgreSQL's enum data type into ActiveRecord's schema and migrations.
Stars: ✭ 227 (+808%)
Mutual labels:  postgres
postgresql lwrp
Express 42 postgresql cookbook
Stars: ✭ 57 (+128%)
Mutual labels:  postgres
Wasmer Postgres
💽🕸 Postgres library to run WebAssembly binaries.
Stars: ✭ 245 (+880%)
Mutual labels:  postgres
heltin
Robust client registry for individuals receiving mental healthcare services.
Stars: ✭ 18 (-28%)
Mutual labels:  postgres
Prest
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new
Stars: ✭ 3,023 (+11992%)
Mutual labels:  postgres
Rpostgres
A DBI-compliant interface to PostgreSQL
Stars: ✭ 245 (+880%)
Mutual labels:  postgres
Pg insights
A collection of convenient SQL for monitoring Postgres database health.
Stars: ✭ 253 (+912%)
Mutual labels:  postgres
Massive Js
A data mapper for Node.js and PostgreSQL.
Stars: ✭ 2,521 (+9984%)
Mutual labels:  postgres
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (+124%)
Mutual labels:  postgres
Sqliterally
Lightweight SQL query builder
Stars: ✭ 231 (+824%)
Mutual labels:  postgres
Flask Boilerplate
Simple flask boilerplate with Postgres, Docker, and Heroku/Zeit now
Stars: ✭ 251 (+904%)
Mutual labels:  postgres
pg-pubsub
Reliable PostgreSQL LISTEN/NOTIFY with inter-process lock support
Stars: ✭ 50 (+100%)
Mutual labels:  postgres
pg-search-sequelize
Postgres full-text search in Node.js and Sequelize.
Stars: ✭ 31 (+24%)
Mutual labels:  postgres
IreneBot
Irene Bot for Discord in Python
Stars: ✭ 15 (-40%)
Mutual labels:  postgres

Logo

/kləNGk/

noun

A heavy, dull sound such as that made by thick pieces of metal striking together.

Talking to Postgres via sockets. At this point in time, I'm just experimenting with Clojure; learning core.async.

Clojure CI

Running The Tests

You need to have a Postgres (13) Database up and running.

docker compose up -d

Now you can run the tests with

clj -X:test

Example

(ns scratch.client
  (:require
   [clojure.core.async :as async]
   [com.clunk.core :as clunk]))

(def cfg {:username "jimmy"
          :password "banana"
          :database "world"
          :debug true})

We can now create a client, and connect to the postgres instance:

(def client (clunk/client cfg))

(clunk/connect client)

We will see a bunch of received messages:

{:type :AuthenticationMD5, :salt #object["[B" 0x5ea94109 "[B@5ea94109"]}
{:type :AuthenticationOk}
{:type :ParameterStatus, :param "application_name", :status ""}
{:type :ParameterStatus, :param "client_encoding", :status "UTF8"}
{:type :ParameterStatus, :param "DateStyle", :status "ISO, MDY"}
{:type :ParameterStatus, :param "integer_datetimes", :status "on"}
{:type :ParameterStatus, :param "IntervalStyle", :status "postgres"}
{:type :ParameterStatus, :param "is_superuser", :status "on"}
{:type :ParameterStatus, :param "server_encoding", :status "UTF8"}
{:type :ParameterStatus, :param "server_version", :status "13.4 (Debian 13.4-1.pgdg100+1)"}
{:type :ParameterStatus, :param "session_authorization", :status "jimmy"}
{:type :ParameterStatus, :param "standard_conforming_strings", :status "on"}
{:type :ParameterStatus, :param "TimeZone", :status "Etc/UTC"}
{:type :BackendKeyData, :id 239, :key 2031531424}
{:type :ReadyForQuery, :status 73}

Finally we can define and run a query. The <query! macro is shorthand for an async take on the channel returned from clunk/query. It must be run inside a go block.

(def qs "SELECT name, region, population FROM country ORDER BY name LIMIT 10;")

(async/go-loop
 []
  (when-let [recv (clunk/<query! client qs)]
    (println recv)
    (recur)))

The above async loop prints out the following:

{:name Afghanistan, :region Southern and Central Asia, :population 22720000}
{:name Albania, :region Southern Europe, :population 3401200}
{:name Algeria, :region Northern Africa, :population 31471000}
{:name American Samoa, :region Polynesia, :population 68000}
{:name Andorra, :region Southern Europe, :population 78000}
{:name Angola, :region Central Africa, :population 12878000}
{:name Anguilla, :region Caribbean, :population 8000}
{:name Antarctica, :region Antarctica, :population 0}
{:name Antigua and Barbuda, :region Caribbean, :population 68000}
{:name Argentina, :region South America, :population 37032000}

And lastly, close the client:

(clunk/close client)

Rough Todo / Help needed

  • Build out CLJS test suite
  • Figure out a good way to provide async query results
  • Fix core.async channel closing issues
  • Flush out frontend/backend message parsers
  • Deploy to Clojars
  • Deploy to npm
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].