-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
25 lines (20 loc) · 998 Bytes
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns sqlforcql.core
(:require [sqlforcql.db :as db]
[sqlforcql.atoms :as atoms]))
(defn connect-to-default-db
"Connect to a Cassandra keyspace on a particular ip-address, with the given username and password, and store
this information in atoms/default-db-map map."
([] (connect-to-default-db "keyspace-name"))
([keyspace] (let [db-map (db/connect-to-db "localhost" 9042 "cassandra" "cassandra" keyspace)]
(reset! atoms/default-db-map db-map)))
([ip-address port username password keyspace]
(let [db-map (db/connect-to-db ip-address port username password keyspace)]
(reset! atoms/default-db-map db-map))))
(defn disconnect-from-default-db
"Disconnect from Cassandra using information stored in atoms/default-db-map map."
[]
(db/disconnect-from-db (deref atoms/default-db-map)))
(comment
(require '[sqlforcql.core :as core])
(core/connect-to-default-db "localhost" "username" "password" "keyspace")
(core/disconnect-from-default-db))