【发布时间】:2015-01-04 01:30:54
【问题描述】:
我在使用 cassandra 的 ruby 中插入查询时遇到问题,
这是我的桌子:
CREATE TABLE testkeyspace.ticket (
id int,
uid text,
annule boolean,
avoir decimal,
caisse int,
clotureid int,
couverts decimal,
creation_iso timestamp,
modif_iso timestamp,
montantencaisse decimal,
montantttc decimal,
nb_articles int,
numero int,
remise decimal,
remise_montant decimal,
remise_type text,
remise_valeur decimal,
rendu decimal,
stats_iso timestamp,
PRIMARY KEY (id, uid)
)
在 ruby 中我做了一个准备声明:
insert_table_ticket = session.prepare("INSERT INTO ticket(id, uid, annule, avoir, caisse, clotureid, couverts,creation_iso, modif_iso, montantencaisse, montantttc, nb_articles, numero, remise,remise_montant, remise_type, remise_valeur, rendu,stats_iso) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
我把这些值用于测试:
session.execute(insert_table_ticket,
1,
"test",
true,
1.1,
1,
1,
1.0,
1415350203,
1415350203,
1.1,
1.1,
1,
1,
1.1,
1.1,
"tests",
1.1,
1.1,
1415350203
)
我收到了这个错误:
/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/cql_byte_buffer.rb:275:in
to_s': wrong number of arguments (1 for 0) (ArgumentError) from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/cql_byte_buffer.rb:275:inappend_decimal ' 来自/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/type_converter.rb:287:indecimal_to_bytes' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/type_converter.rb:85:incall' 来自 /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/type_converter.rb:85:into_bytes' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/requests/execute_request.rb:93:inblock in encode_values ' 来自/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/requests/execute_request.rb:92:ineach' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/requests/execute_request.rb:92:ineach_with_index ' 来自/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/requests/execute_request.rb:92:inencode_values' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/protocol/requests/execute_request.rb:39:ininitialize ' 来自/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/cluster/client.rb:190:innew' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/cluster/client.rb:190:inexecute' 来自/home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/session.rb:81:inexecute_async' from /home/florian/.rvm/gems/ruby-2.1.4/gems/cassandra-driver-1.0.0.rc.1/lib/cassandra/session.rb:103:inexecute' 来自/home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:60:inblock (3 levels) in <top (required)>' from /home/florian/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/benchmark.rb:279:inmeasure' 来自 /home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:35:inblock (2 levels) in <top (required)>' from /home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:34:ineach' 来自 /home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:34:inblock in <top (required)>' from /home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:33:inexecute' 来自 /home/florian/Projects/hadoop-ticket-server/import_cassandra.rb:33:in<top (required)>' from -e:1:inload' 从 -e:1:in `'
你知道我的问题吗?谢谢你
【问题讨论】:
-
所以你有一个错误指向特定的代码行,所以下一步是查看引用的代码。但是你没有给我们这些信息。
标签: ruby insert cassandra datastax-enterprise