Skip to content

r0man/sqlingvo.node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLingvo.node

https://img.shields.io/clojars/v/sqlingvo.node.svg https://travis-ci.org/r0man/sqlingvo.node.svg http://jarkeeper.com/r0man/sqlingvo.node/status.svg https://jarkeeper.com/r0man/sqlingvo.node/downloads.svg

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.

Usage

Sync

(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"}]

Async

(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"}]

License

Copyright © 2016 r0man

Distributed under the Eclipse Public License, the same as Clojure.

About

A ClojureScript driver for SQLingvo on Node.js.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published