A C++ wrapper for the Datastax Cassandra C/C++ driver meant to actually use proper C++ memory safe techniques(?).
It uses some heinous form of RAII that I came up with while sleep deprived and high on jaffacakes.
Its meant to provide a simillar programming interface to the mysql xdevapi. Simillar is doing some heavy lifting here as it currently supports veeeery limited functionality :(
TODO - add proper commands and examples for building and usage
- Clone this repository
- Recursively init submodules
- Build like a normal cmake application in some build directory
-
Add the include folder to your project's header paths
-
Link against:
- build_directory/libcassandra_static.a
- build_directory/libcassandra_cpp_wrapper.a
- OpenSSL (OpenSSL::SSL)
- ZLib (ZLIB::ZLIB)
- libuv
-
Use :3
casswrap::SessionSettings databaseConenctionSeetings { .host = "192.168.1.2", .port = 0, //uhhh this doesn't do anything right now .user = "username", .password = "meow", .keyspace = "meow_keyspace" }; //or use new and a pointer //should be thread safe? I think? I've used it as a singleton in an event loop thingy concurrently without issues! //(and the underlying CassSession* pointer is thread safe so should be fine!) casswrap::Session cassandraSession(databaseConenctionSeetings); std::string cqlStr = "INSERT INTO meow_keyspace.kitty_details (kitty_uuid, type, name, num_ears) VALUES (?, ?, ?)"; cassandraSession.sql(cqlStr) .bindUUID(kittyUuidString) .bind("Meowy") .bind(int64_t(2)) //a bunch of bind types are supported, check out SqlStatement.h for all of them :D .executeAsync(); //yeeee non-blocking is a thing! //and to get stuff: std::string cqlString = "SELECT name, num_ears FROM meow_keyspace.kitty_details WHERE type = ?"; casswrap::RowResult results cassandraSession.sql(cqlStr).bind("mainecoon").execute(); //results.count() returns the number of rows in the result of the operation for (int rowIndex = 0; rowIndex < results.count(); rowIndex++){ //everytime its called, fetchOne() will return the next consecutive row //each row is an "array" of values (each element is the value of the corresponding queried column) std::cout << "Name: " << results.fetchOne()[0].getString(); << std::endl; }Have a read through the .h files to see all the available functionality!