SQLingvo.node is a SQLingvo driver for ClojureScript on Node.js. It uses core.async and the pg or pg-native libraries to connect to a database and execute SQL statements.
(ns sqlingvo.node.sync-usage
(:require [cljs.pprint :refer [pprint]]
[sqlingvo.core :as sql]
[sqlingvo.node.sync :as db]))
(def db (db/db "postgresql://tiger:scotch@localhost/sqlingvo_node"))
(pprint @(sql/select db [:*]
(sql/from :information_schema.tables)
(sql/where '(= :table_name "pg_statistic"))))[{:is_insertable_into "YES",
:self_referencing_column_name nil,
:user_defined_type_catalog nil,
:table_type "BASE TABLE",
:table_schema "pg_catalog",
:is_typed "NO",
:user_defined_type_schema nil,
:user_defined_type_name nil,
:commit_action nil,
:table_catalog "sqlingvo_node",
:reference_generation nil,
:table_name "pg_statistic"}]
(ns sqlingvo.node.async-usage
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :as async]
[cljs.pprint :refer [pprint]]
[sqlingvo.core :as sql]
[sqlingvo.node.async :as db :refer-macros [<? <!?]]))
(def db (db/db "postgresql://tiger:scotch@localhost/sqlingvo_node"))
(go (let [db (<? (db/connect db))]
(pprint (<!? (sql/select db [:*]
(sql/from :information_schema.tables)
(sql/where '(= :table_name "pg_statistic")))))
(db/disconnect db)))[{:is_insertable_into "YES",
:self_referencing_column_name nil,
:user_defined_type_catalog nil,
:table_type "BASE TABLE",
:table_schema "pg_catalog",
:is_typed "NO",
:user_defined_type_schema nil,
:user_defined_type_name nil,
:commit_action nil,
:table_catalog "sqlingvo_node",
:reference_generation nil,
:table_name "pg_statistic"}]
Copyright © 2016 r0man
Distributed under the Eclipse Public License, the same as Clojure.