No description
Find a file
Yuriy Glukhov 1399234e91
Merge pull request #7 from riinr/toString
feat(asyncwrapper): more types to string
2023-09-22 19:32:47 +02:00
.github/workflows Add CI 2023-04-30 23:10:44 +09:00
cassandra Merge pull request #7 from riinr/toString 2023-09-22 19:32:47 +02:00
genbindings init 2017-07-21 02:17:42 +03:00
tests Remove warnings 2023-05-01 21:58:19 +09:00
.gitignore Initial commit 2017-07-21 01:31:13 +03:00
cassandra.nim Higher level async api 2017-07-21 17:44:42 +03:00
cassandra.nimble Added skipDirs 2017-07-21 02:24:42 +03:00
cibuild.sh Higher level async api 2017-07-21 17:44:42 +03:00
LICENSE Initial commit 2017-07-21 01:31:13 +03:00
README.md Updated build status badge 2023-04-30 21:49:33 +02:00

cassandra Build Status

Nim bindings to cassandra db driver

Usage

import asyncdispatch, cassandra

proc 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:

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 - most likely, you'll have to build it yourself
  • libuv - check out your package manager, most likely it will be there