-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Fern Flower Lab | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,105 @@ | ||
= The SQL Graph in Clojure | ||
|
||
Utilizes Tinkerpop3 graph over SQL database using `sqlg`. | ||
|
||
== Supported DBs | ||
|
||
. PostgreSQL | ||
. MySQL | ||
. MariaDB | ||
. HSQLDB | ||
. H2 | ||
. MSSQL | ||
|
||
CAUTION: The low-level drive well tested only with PostgreSQL + C3P0. You are warned. | ||
|
||
== Config | ||
|
||
Basic config is represented by `sample.properties` | ||
|
||
[source,properties] | ||
---- | ||
sample.graph.db.type = postgresql | ||
sample.graph.db.host = localhost | ||
sample.graph.db.port = 5432 | ||
sample.graph.db.name = sample | ||
sample.graph.db.user = username | ||
sample.graph.db.pass = password | ||
---- | ||
|
||
In order to get it prepared use | ||
|
||
[source,clojure] | ||
---- | ||
user=> (require '[sqlg-clj.config :as c]) | ||
user=> (def config (-> "sample" c/load-config :sample :graph :db c/db-config)) | ||
---- | ||
|
||
Same result may be done using EDN config, i.e. directly from your app: | ||
|
||
[source,clojure] | ||
---- | ||
user=> (def config (c/db-config {:port 5432 :pass "password" :user "username" :type "postgresql" :host "localhost" :name "sample"})) | ||
---- | ||
|
||
When the config is ready it may be easily read back | ||
|
||
[source,clojure] | ||
---- | ||
user=>(c/config->clj config) | ||
{"jdbc.url" "jdbc:postgresql://localhost:5432/sample", "jdbc.username" "username", "jdbc.password" "password"} | ||
---- | ||
|
||
=== Starting | ||
|
||
Open SqlgGraph directly | ||
|
||
[source,clojure] | ||
---- | ||
(def G (c/graph config)) | ||
---- | ||
|
||
or indirectly | ||
|
||
[source,clojure] | ||
---- | ||
(def G (c/open-graph config)) | ||
---- | ||
|
||
The last method opens a new TinkerGraph with default configuration or open a new Graph instance with the specified configuration. | ||
The configuration may be a path to a file or a Map of configuration options. | ||
When gets prepared BaseConfiguration or Configuration object as an argument - returns SqlgGraph. | ||
|
||
=== Using | ||
|
||
[source,clojure] | ||
---- | ||
user=> (-> ^Graph G traversal V (has-label "label")) | ||
#object[org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal 0x3fffba3f "[GraphStep(vertex,[]), HasStep([~label.eq(label)])]"] | ||
---- | ||
|
||
=== Transactions | ||
|
||
In order to store or to unroll the changes were made by some iteration between calls, use | ||
|
||
[source,clojure] | ||
---- | ||
user=> (require '[sqlg-clj.util :as u]) | ||
user=> (u/commit! G) | ||
;; or | ||
user=> (u/rollback! G) | ||
---- | ||
|
||
respectively. | ||
|
||
=== More info | ||
|
||
Please, read original documentation http://sqlg.org[here] | ||
|
||
== License | ||
|
||
© 2022 Fern Flower Lab | ||
© | ||
|
||
2022 Fern Flower Lab | ||
|
||
Distributed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sample.graph.db.type = postgresql | ||
sample.graph.db.host = localhost | ||
sample.graph.db.port = 5432 | ||
sample.graph.db.name = sample | ||
sample.graph.db.user = username | ||
sample.graph.db.pass = password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters