SELECT 错误 Cassandra 'Row' 对象没有属性 'values'
SELECT Error Cassandra 'Row' object has no attribute 'values'
我正在尝试在本地 docker (https://hub.docker.com/_/cassandra/) 中设置和 运行 Cassandra 3.10。一切顺利,直到我尝试从一个 table.
select
这是我每次 运行 select whatever from whatever:
时得到的错误
'Row' object has no attribute 'values'
我遵循的步骤:
我使用默认超级用户 cassandra 创建了一个新的密钥空间。创建 keyspace test with replication = {'class':'SimpleStrategy','replication_factor' : 2};
和 USE test;
我创建了一个新的table:create table usertable (userid int primary key, usergivenname varchar, userfamilyname varchar, userprofession varchar);
插入一些数据:insert into usertable (userid, usergivenname, userfamilyname, userprofession) values (1, 'Oliver', 'Veits', 'Freelancer');
尝试select:select * from usertable where userid = 1;
我的步骤来自:https://oliverveits.wordpress.com/2016/12/08/cassandra-hello-world-example/ 只是为了复制和粘贴一些工作代码(我对语法和拼写错误很生气)
这是我的 docker 图片的日志:
INFO [Native-Transport-Requests-1] 2017-04-23 19:09:12,543 MigrationManager.java:303 - Create new Keyspace: KeyspaceMetadata{name=test2, params=KeyspaceParams{durable_writes=true, replication=ReplicationParams{class=org.apache.cassandra.locator.SimpleStrategy, replication_factor=2}}, tables=[], views=[], functions=[], types=[]}
INFO [Native-Transport-Requests-1] 2017-04-23 19:09:41,415 MigrationManager.java:343 - Create new table: org.apache.cassandra.config.CFMetaData@1b484e82[cfId=6757f460-2858-11e7-9787-6d2c86545d91,ksName=test2,cfName=usertable,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={min_threshold=4, max_threshold=32}}, compression=org.apache.cassandra.schema.CompressionParams@4bce743f, extensions={}, cdc=false},comparator=comparator(),partitionColumns=[[] | [userfamilyname usergivenname userprofession]],partitionKeyColumns=[userid],clusteringColumns=[],keyValidator=org.apache.cassandra.db.marshal.Int32Type,columnMetadata=[usergivenname, userprofession, userid, userfamilyname],droppedColumns={},triggers=[],indexes=[]]
INFO [MigrationStage:1] 2017-04-23 19:09:41,484 ColumnFamilyStore.java:406 - Initializing test2.usertable
INFO [IndexSummaryManager:1] 2017-04-23 19:13:25,214 IndexSummaryRedistribution.java:75 - Redistributing index summaries
非常感谢!
更新
我用这样的 uuid 列创建了另一个 table:"uid uuid primary key"。它在 table 为空但插入一次后出现相同的错误
我遇到了同样的问题,我正在使用 cqlsh。你只需要重新加载。可能是第一次或创建模式后的 cqlsh 错误。
~$ sudo docker run --name ex1 -d cassandra:latest
9c1092938d29ec7f94bee773cc2adc0a23ff09344e32500bfeb1898466610d06
~$ sudo docker exec -ti ex1 /bin/bash
root@9c1092938d29:/# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> CREATE SCHEMA simple1
... WITH replication={
... 'class': 'SimpleStrategy',
... 'replication_factor':1};
cqlsh> use simple1;
cqlsh:simple1> create table users(id varchar primary key, first_name varchar, last_name varchar);
cqlsh:simple1> select * from users;
id | first_name | last_name
----+------------+-----------
(0 rows)
cqlsh:simple1> insert into users(id, first_name, last_name) values ('U100001', 'James', 'Jones');
cqlsh:simple1> select * from users;
'Row' object has no attribute 'values'
cqlsh:simple1> quit
root@9c1092938d29:/# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> use simple1;
cqlsh:simple1> select * from users;
id | first_name | last_name
---------+------------+-----------
U100001 | James | Jones
(1 rows)
我正在尝试在本地 docker (https://hub.docker.com/_/cassandra/) 中设置和 运行 Cassandra 3.10。一切顺利,直到我尝试从一个 table.
select这是我每次 运行 select whatever from whatever:
时得到的错误'Row' object has no attribute 'values'
我遵循的步骤:
我使用默认超级用户 cassandra 创建了一个新的密钥空间。创建
keyspace test with replication = {'class':'SimpleStrategy','replication_factor' : 2};
和USE test;
我创建了一个新的table:
create table usertable (userid int primary key, usergivenname varchar, userfamilyname varchar, userprofession varchar);
插入一些数据:
insert into usertable (userid, usergivenname, userfamilyname, userprofession) values (1, 'Oliver', 'Veits', 'Freelancer');
尝试select:
select * from usertable where userid = 1;
我的步骤来自:https://oliverveits.wordpress.com/2016/12/08/cassandra-hello-world-example/ 只是为了复制和粘贴一些工作代码(我对语法和拼写错误很生气)
这是我的 docker 图片的日志:
INFO [Native-Transport-Requests-1] 2017-04-23 19:09:12,543 MigrationManager.java:303 - Create new Keyspace: KeyspaceMetadata{name=test2, params=KeyspaceParams{durable_writes=true, replication=ReplicationParams{class=org.apache.cassandra.locator.SimpleStrategy, replication_factor=2}}, tables=[], views=[], functions=[], types=[]}
INFO [Native-Transport-Requests-1] 2017-04-23 19:09:41,415 MigrationManager.java:343 - Create new table: org.apache.cassandra.config.CFMetaData@1b484e82[cfId=6757f460-2858-11e7-9787-6d2c86545d91,ksName=test2,cfName=usertable,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={min_threshold=4, max_threshold=32}}, compression=org.apache.cassandra.schema.CompressionParams@4bce743f, extensions={}, cdc=false},comparator=comparator(),partitionColumns=[[] | [userfamilyname usergivenname userprofession]],partitionKeyColumns=[userid],clusteringColumns=[],keyValidator=org.apache.cassandra.db.marshal.Int32Type,columnMetadata=[usergivenname, userprofession, userid, userfamilyname],droppedColumns={},triggers=[],indexes=[]]
INFO [MigrationStage:1] 2017-04-23 19:09:41,484 ColumnFamilyStore.java:406 - Initializing test2.usertable
INFO [IndexSummaryManager:1] 2017-04-23 19:13:25,214 IndexSummaryRedistribution.java:75 - Redistributing index summaries
非常感谢!
更新
我用这样的 uuid 列创建了另一个 table:"uid uuid primary key"。它在 table 为空但插入一次后出现相同的错误
我遇到了同样的问题,我正在使用 cqlsh。你只需要重新加载。可能是第一次或创建模式后的 cqlsh 错误。
~$ sudo docker run --name ex1 -d cassandra:latest
9c1092938d29ec7f94bee773cc2adc0a23ff09344e32500bfeb1898466610d06
~$ sudo docker exec -ti ex1 /bin/bash
root@9c1092938d29:/# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> CREATE SCHEMA simple1
... WITH replication={
... 'class': 'SimpleStrategy',
... 'replication_factor':1};
cqlsh> use simple1;
cqlsh:simple1> create table users(id varchar primary key, first_name varchar, last_name varchar);
cqlsh:simple1> select * from users;
id | first_name | last_name
----+------------+-----------
(0 rows)
cqlsh:simple1> insert into users(id, first_name, last_name) values ('U100001', 'James', 'Jones');
cqlsh:simple1> select * from users;
'Row' object has no attribute 'values'
cqlsh:simple1> quit
root@9c1092938d29:/# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> use simple1;
cqlsh:simple1> select * from users;
id | first_name | last_name
---------+------------+-----------
U100001 | James | Jones
(1 rows)