欢迎投稿

今日深度:

python 连接cassandra数据库,pythoncassandra

python 连接cassandra数据库,pythoncassandra


cassandra比mysql快(其实这是一种错误的理解方式)点击打开链接

但cassandra做group,order by操作时比较麻烦,看文章【cassandra的索引查询和排序】点击打开链接


from cassandra.cluster import Cluster
from cassandra.query import tuple_factory
from cassandra.policies import DCAwareRoundRobinPolicy
from cassandra.policies import DowngradingConsistencyRetryPolicy
from cassandra import ConsistencyLevel
from cassandra.query import dict_factory
import sys


clusterList=['cassandra服务器ip','cassandra服务器ip', 'cassandra服务器ip']


'''load_balancing_policy是负载均衡,default_retry_policy是重试策略'''
cluster=Cluster(clusterList,load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='DC2'),default_retry_policy=DowngradingConsistencyRetryPolicy())
session=cluster.connect("数据库名")
'''cassandra数据的一致性'''
session.default_consistency_level  = ConsistencyLevel.LOCAL_QUORUM


data=session.execute("select * from 表名 where xxx")
print data
cassandra的数据一致性:
http://blog.csdn.net/u010003835/article/details/53432627

我使用的是LOCAL_QUORUM

www.htsjk.Com true http://www.htsjk.com/cassandra/25550.html NewsArticle python 连接cassandra数据库,pythoncassandra cassandra比mysql快(其实这是一种错误的理解方式)点击打开链接 但cassandra做group,order by操作时比较麻烦,看文章【cassandra的索引查询和排序】点击...
相关文章
    暂无相关文章
评论暂时关闭