Hi folks!
I want to use ORM from [DataStax Python Driver][1] for Cassandra DB (create some class with data and automatically create a table from it without writing too much CQL = )
I've deployed a Cassandra server on localhost via docker and tried to do just like it's written in manual
from cassandra.cluster import Cluster from cassandra.cqlengine import columns from cassandra.cqlengine.models import Model from cassandra.cqlengine.management import sync_table, create_keyspace_simple class Person(Model): __keyspace__ = 'mega_keyspace' __table_name__ = 'person' id = columns.UUID(primary_key=True) first_name = columns.Text() last_name = columns.Text() if __name__ == "__main__": cluster = Cluster() session = cluster.connect() # create_keyspace_simple("mega_keyspace", 2) session.execute("CREATE KEYSPACE IF NOT EXISTS mega_keyspace WITH REPLICATION = " "{ 'class' : 'SimpleStrategy', 'replication_factor' : 2 };") # keyspace created okay sync_table(Person) # And here's the exception = (
But alas, sync_table(...) gives me an error:
cassandra.cqlengine.CQLEngineException: Connection name '<object object at 0x7fbd95322ab0>' doesn't exist in the registry.
How can I fix it?