Problem using sync_type from cassandra-python-driver

3

I'm using userType but I get this error

Traceback (most recent call last):   
File "cassandra-test.py", line 70, in <module>
    sync_type(Image) 
TypeError: sync_type() missing 1 required positional argument: 'type_model'

The code I am using is:

from cassandra.cqlengine import columns
from cassandra.cqlengine import connection
from cassandra.cqlengine.management import sync_table, sync_type

class Image(UserType):
    path_to_images = columns.Text()
    images = columns.Map(columns.Text(), columns.Text())

class User(Model):
    __table_name__ = 'auth_user'
    id = columns.TimeUUID(primary_key=True, default=uuid.uuid4)
    firstName = columns.Text()
    lastName = columns.Text()
    email = columns.Text()
    password = columns.Text()
    images = columns.UserDefinedType(Image)

sync_type(Image)
sync_table(User)
    
asked by EdgarAlejandro 31.07.2017 в 17:04
source

1 answer

1

The sync_type function expect you to pass at least two parameters:

def sync_type(ks_name, type_model, connection=None):
    # ...

Therefore, you must execute it in the following way (using the keyspace of your connection):

sync_type('cqlengine', Image)

The problem was that you were just passing the guy.

    
answered by 31.07.2017 / 17:32
source