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

11,082

The instructions for creating the 'demo' keyspace are at a page linked from 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/

The try-cassandra page has a link for the developer walkthrough (click on "Start Developer Walkthrough"). The developer walk through has a step for creating the 'demo' keyspace:

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 };

To create the table

use demo;
CREATE TABLE users (
  firstname text,
  lastname text,
  age int,
  email text,
  city text,
PRIMARY KEY (lastname));
Share:
11,082
micheal
Author by

micheal

Updated on June 04, 2022

Comments

  • micheal
    micheal almost 2 years

    I'm trying to use python driver for cassandra but when I run these three lines in 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 keyspace named 'demo' but I'm just following these two tutorials and they haven't said anything about pre creating keyspace http://planetcassandra.org/getting-started-with-cassandra-and-python/ http://datastax.github.io/python-driver/getting_started.html

  • Aaron
    Aaron about 9 years
    Good find, Andy. I also thought that was odd that they didn't include the CREATE KEYSPACE statement.