本文介绍了阅读Cassandra 1.2表与pycassa的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Cassandra 1.2。我使用CQL 3创建了一个表格,如下:

  CREATE TABLE foo(
user text PRIMARY KEY,
电子邮件集< text>
);

现在我想通过pycassa查询数据:

  import pycassa 
from pycassa.pool import ConnectionPool
pool = ConnectionPool('ks1',['localhost:9160'])
foo = pycassa.ColumnFamily(pool,'foo')

这给我

 跟踪(最近一次调用):
文件test.py,第5行,在< module>
foo = pycassa.ColumnFamily(pool,'foo')
文件/home/john/src/pycassa/lib/python2.7/site-packages/pycassa/columnfamily.py,第284行,in __init__
self.load_schema()
文件/home/john/src/pycassa/lib/python2.7/site-packages/pycassa/columnfamily.py,第312行,在load_schema
raise nfe
pycassa.cassandra.ttypes.NotFoundException:NotFoundException(_message = None,why ='Column family foo not found。)
解决方案

如果您已经创建了表使用CQL3,你想通过基于thrift的客户端访问它们;您将必须指定紧凑存储属性。例如:

  CREATE TABLE dummy_file_test 

dtPtn INT,
pxID INT,
startTm INT,
endTm INT,
patID BIGINT,
efile BLOB,
PRIMARY KEY((dtPtn,pxID,startTm))

这是我在访问基于CQL3的列使用Pycassa时所必须做的


Using Cassandra 1.2. I created a table using CQL 3 the following way:

CREATE TABLE foo (
    user text PRIMARY KEY,
    emails set<text>
);

Now I am trying to query the data through pycassa:

import pycassa
from pycassa.pool import ConnectionPool
pool = ConnectionPool('ks1', ['localhost:9160'])
foo = pycassa.ColumnFamily(pool, 'foo')

This gives me

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    foo = pycassa.ColumnFamily(pool, 'foo')
  File "/home/john/src/pycassa/lib/python2.7/site-packages/pycassa/columnfamily.py", line 284, in __init__
    self.load_schema()
  File "/home/john/src/pycassa/lib/python2.7/site-packages/pycassa/columnfamily.py", line 312, in load_schema
    raise nfe
pycassa.cassandra.ttypes.NotFoundException: NotFoundException(_message=None, why='Column family foo not found.')

How can this be accomplished?

解决方案

If you have created your tables using CQL3 and you want to access them through a thrift based client; you will have to specify the Compact Storage property. e.g :

CREATE TABLE dummy_file_test
(
 dtPtn          INT,
 pxID           INT,
 startTm        INT,
 endTm          INT,
 patID          BIGINT,
 efile          BLOB,
 PRIMARY KEY((dtPtn, pxID, startTm))
)with compact storage;  

This is what i had to do while accessing CQL3 based column Families with Pycassa

这篇关于阅读Cassandra 1.2表与pycassa的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:27