cassandra-driver from DataStax: How to create Cassandra DB table from a Model?

Author: Felix

Originally Sourced from:

I want to use ORM from DataStax Python Driver 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 their manual:

from cassandra.cluster import Cluster

from cassandra.cqlengine import columns
from cassandra.cqlengine.models import Model
from 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 is created okay...
    sync_table(Person)  # And here's the error appears!

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?