A Crystal wrapper around the Crystal DB API for Cassandra and C/C++ Driver for ScyllaDB.
Explore the ScyllaDB docs »
Report Bug
·
Request Feature
This project aims to build an environment for interoperability and use of ScyllaDB with the Crystal programming language, aiming at building a driver and wrapper for communication.
Please make sure you have installed the C/C++ Driver for ScyllaDB.
Then add this to your application's shard.yml
:
dependencies:
scylladb:
github: lanjoni/scylladb-crystal-driver
From the basic example:
require "scylladb/dbapi"
DB.open("scylladb://127.0.0.1/test") do |db|
db.exec(<<-CQL)
create table posts (
id timeuuid primary key,
title text,
body text,
created_at timestamp
)
CQL
db.exec("insert into posts (id, title, body, created_at) values (now(), ?, ?, ?)",
"Hello World",
"Hello, World. I have a story to tell.",
Time.now)
db.query("select title, body, created_at from posts") do |rs|
rs.each do
title = rs.read(String)
body = rs.read(String)
created_at = rs.read(Time)
puts title
puts "(#{created_at})"
puts body
end
end
end
Please refer to crystal-db for further usage instructions.
scylladb-crystal-driver
supports all the DB::Any
primitive types plus Int8
, Int16
and some additional value types:
date
maps toScyllaDB::DBApi::Date
time
maps toScyllaDB::DBApi::Time
uuid
maps toScyllaDB::DBApi::Uuid
timeuuid
maps toScyllaDB:DBApi::TimeUuid
Some of the collection types are also supported:
list
maps toArray
set
maps toSet
map
maps toHash
After installation is complete run:
$ crystal spec
This command runs the tests to verify that everything is working correctly.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
- lanjoni - João Lanjoni <[email protected]> (he/him)