python - cassandra.InvalidRequest : code=2200 [Invalid query] message ="Keyspace ' ' does not exist"

标签 python cassandra cassandra-2.0

我正在尝试使用 python driver for cassandra 但是当我在 python shell 中运行这三行时

from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('demo')

我收到这个错误

cassandra.InvalidRequest: code=2200 [Invalid query] message="Keyspace 'demo' does not exist"

pip freeze 说 cassandra-driver==2.5.0

我检查了cqlsh

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.4 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh> describe keyspaces

system_traces  system

cqlsh> 

没有名为“demo”的键空间,但我只是在学习这两个教程,他们没有说任何关于预创建键空间的内容 http://planetcassandra.org/getting-started-with-cassandra-and-python/ http://datastax.github.io/python-driver/getting_started.html

最佳答案

创建“演示”键空间的说明位于从 http://planetcassandra.org/getting-started-with-cassandra-and-python/ 链接的页面上:

To follow this tutorial, you should already have a running Cassandra instance, and have gone through the 10 minute walkthrough here: http://www.PlanetCassandra.org/try-cassandra/

try-cassandra 页面有开发人员演练的链接(单击“开始开发人员演练”)。开发人员演练有一个创建“演示”键空间的步骤:

The keyspace can include operational elements, such as replication factor and data center awareness. Let’s create a keyspace called “demo”. We will include replication strategy class and factor; details that will be covered in a future tutorial.

To create the keyspace “demo”, at the CQL shell prompt, type:

cqlsh> CREATE KEYSPACE demo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

创建表

use demo;
CREATE TABLE users (
  firstname text,
  lastname text,
  age int,
  email text,
  city text,
PRIMARY KEY (lastname));

关于python - cassandra.InvalidRequest : code=2200 [Invalid query] message ="Keyspace ' ' does not exist",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29496724/

相关文章:

javascript - 范围错误: index out of range when connect to cassandra databse in node js

python - django celery 只调用 2 个 apply_async 任务中的 1 个

python - 线路安排问题。 (有人可以提出一个更省时的解决方案吗?)

python - python 密码强度检查器

apache-spark - Spark Cassandra : join table with condition on the query based on attribute from the primary RDD ("where tableA.myValue > tableB.myOtherValue")

performance - Cassandra - 单节点单表批量插入性能较差

ntp - Cassandra 节点不同步 - NTP 不同步问题

java - Cassandra 2.0支持的hadoop版本是什么

cassandra - 我怎么知道 nodetool 修复是否完成

python - 如何重新排序Python十六进制字符串中的字节并转换为长整型