https://github.com/yglukhov/cassandra
Nim bindings to cassandra db driver
https://github.com/yglukhov/cassandra
Last synced: 7 months ago
JSON representation
Nim bindings to cassandra db driver
- Host: GitHub
- URL: https://github.com/yglukhov/cassandra
- Owner: yglukhov
- License: mit
- Created: 2017-07-20T22:31:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-22T17:32:48.000Z (about 2 years ago)
- Last Synced: 2025-01-24T22:27:14.360Z (9 months ago)
- Language: Nim
- Size: 201 KB
- Stars: 15
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cassandra [](https://github.com/yglukhov/cassandra/actions?query=branch%3Amaster)
Nim bindings to cassandra db [driver](https://github.com/datastax/cpp-driver)# Usage
```nim
import asyncdispatch, cassandraproc test() {.async.} =
let cluster = newCluster()
let session = newSession()# Add contact points
cluster.setContactPoints("127.0.0.1")# Provide the cluster object as configuration to connect the session
discard await session.connect(cluster)
echo "Connected"let statement = newStatement("SELECT * FROM system.schema_keyspaces WHERE keyspace_name = ?")
statement[0] = "system"
let res = await session.execute(statement)
let val = res.firstRow.columns["strategy_class"]
let cl = val.string
echo "result: ", val
assert(cl == "org.apache.cassandra.locator.LocalStrategy")waitFor test()
```
# Lower level
While high level bindings are still in development you can use low level bindings generated directly from `cassandra.h`. You can always take underlying binding type value from higher level api types. As an option, contributions are welcome ;)Example of mixing two APIs:
```nim
import cassandra
import cassandra/bindings # Low-level bindings
let cluster = newCluster()
let session = newSession()# Add contact points
discard cass_cluster_set_contact_points(cluster.o, "127.0.0.1") # Note: .o is the low-level type
```
# Dependencies
- [libcassandra](https://github.com/datastax/cpp-driver) - most likely, you'll have to build it yourself
- [libuv](https://github.com/libuv/libuv) - check out your package manager, most likely it will be there