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

I am trying to use the python driver for cassandra but when I run these three lines in the python shell

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

I get this error

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

pip freeze says cassandra-driver==2.5.0

I checked 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> 

there is no key space called "demo", but I just follow these two tutorials and they didn't say anything about creating the key http://planetcassandra.org/getting-started-with-cassandra-and-python/ http: // datastax .imtqy.com / python-driver / getting_started.html

+4
source share
1 answer

"" , http://planetcassandra.org/getting-started-with-cassandra-and-python/:

, Cassandra, 10- : http://www.PlanetCassandra.org/try-cassandra/

try-cassandra ( " " ). "" :

, . "demo". ; , .

"demo" , CQL :

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));
+3

All Articles