kaukas / crystal-cassandra Goto Github PK
View Code? Open in Web Editor NEWA Cassandra driver for Crystal
License: MIT License
A Cassandra driver for Crystal
License: MIT License
Hello,
I am trying to execute the following statements:
stmt = <<-CQL
begin batch
insert into #{@tbl_customer} (team_id) values (?) if not exists
update #{@tbl_customer} set customer_id = ?, created_at = ? where team_id = ?
apply batch
CQL
@db.exec stmt, team_id, cust_id, now, team_id
However, I am getting the following error when @db.exec
executes:
ErrorServerProtocolError: Consistency level for LWT is missing for a request with conditions
To fix this, I am trying to set consistency level like this:
Cassandra::LibCass.execution_profile_set_consistency(profile, Cassandra::LibCass::CassConsistency::ConsistencyAny)
Cassandra::LibCass.execution_profile_set_serial_consistency(profile, Cassandra::LibCass::CassConsistency::ConsistencySerial)
stmt = <<-CQL
begin batch
insert into #{@tbl_customer} (team_id) values (?) if not exists
update #{@tbl_customer} set customer_id = ?, created_at = ? where team_id = ?
apply batch
CQL
@db.exec stmt, team_id, cust_id, now, team_id
However, seeing consistency in the profile does not seem to make any difference.
cc: @kaukas
Hello,
Just upgraded to Crystal 0.36.0 and seeing the following error when trying to compile the project:
In lib/cassandra/src/cassandra/dbapi/session.cr:9:5
9 | class Session < DB::Connection
^
Error: abstract `def DB::Connection#build_prepared_statement(query)` must be implemented by Cassandra::DBApi::Session
Hello,
I'm getting an error on a user defined frozen hash field. The error is:
Unhandled exception: Missing hash key: ValueTypeUdt (KeyError)
from /usr/lib/crystal/hash.cr:1027:11 in '[]'
from lib/cassandra/src/cassandra/dbapi/decoders.cr:47:11 in 'get_decoder'
from lib/cassandra/src/cassandra/dbapi/decoders.cr:297:11 in 'decode_with_type'
from lib/cassandra/src/cassandra/dbapi/decoders.cr:13:13 in 'decode'
from lib/cassandra/src/cassandra/dbapi/result_set.cr:126:9 in 'read'
from lib/db/src/db/result_set.cr:79:15 in 'read'
from src/ip-affinities.cr:17:18 in '__crystal_main'
from /usr/lib/crystal/crystal/main.cr:105:5 in 'main_user_code'
from /usr/lib/crystal/crystal/main.cr:91:7 in 'main'
from /usr/lib/crystal/crystal/main.cr:114:3 in 'main'
from __libc_start_main
from _start
from ???
The actual field causing the issue is defined as:
site_sections map<text, frozen<engagement_data>>,
engagement_data is defined as:
create type engagement_data (
first_seen timestamp,
last_seen timestamp,
blink_total int,
scan_total int,
read_total int,
score float,
total_seconds int,
total_read_seconds int
);
We have a lot of these nested custom types. Is there any way to allow them? Sorry if I'm missing something apparent, I'm also a crystal newb. The actual crystal code causing the issue is:
def get_sections(db, did)
db.query("select did, site_sections from users where did=?", did) do |res|
res.each do
did = res.read(String)
sections = res.read(Any)
yield sections
end
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.