Hi,
I am getting the below error while using the sync_table in cqlengine. There was a similar issue seen by an other user. The resolution was to connect to the database first.I did connect to the database , and have verified the connection.With the same session object, I was even able to execute a query. I am trying to come up with a module similar to rails migration for my project.
"CQLENG_ALLOW_SCHEMA_MANAGEMENT" is the warning causing this error. I was not able to find enough documentation regarding this warning.
session = connection.get_session()
cluster = session.cluster
metadata=cluster.metadata
for host in metadata.all_hosts():
log.info("Datacenter = %s Host = %s , Rack = %s",host.datacenter, host.address,host.rack)
class MigrationTable(Model):
uid = columns.UUID(primary_key=True,default=uuid.uuid4)
migrationversion = columns.Text(required=True)
updateddate = columns.DateTime(required=True)
sync_table(MigrationTable)
2015-12-27 16:38:24,084 INFO [myproject.scripts.initializecdb:79][MainThread] Datacenter = datacenter1 Host = 127.0.0.1 , Rack = rack1
2015-12-27 16:38:24,085 INFO [myproject.scripts.initializecdb:81][MainThread] Connected to database with user myproject and myproject
2015-12-27 16:38:24,085 INFO [myproject.scripts.initializecdb:99][MainThread] Datacenter = datacenter1 Host = 127.0.0.1 , Rack = rack1
MigrationTable <uid=b6cc3e03-7804-4299-84c8-6869f03c87df>
201506134065
2015-12-27 22:38:24.086128+00:00
2015-12-27 16:38:24,086 INFO [myproject.scripts.initializecdb:115][MainThread] Creating migration table in the myproject
<class 'myproject.cmodels.migration.MigrationTable'>
/home/izero/devel/my_project/my_project_env/lib/python3.4/site-packages/cassandra/cqlengine/management.py:419: UserWarning: CQLENG_ALLOW_SCHEMA_MANAGEMENT environment variable is not set. Future versions of this package will require this variable to enable management functions.
warnings.warn(msg)
Traceback (most recent call last):
File "/home/izero/devel/my_project/my_project_env/bin/initialize_myproject_cdb", line 9, in <module>
load_entry_point('myproject==0.0', 'console_scripts', 'initialize_myproject_cdb')()
File "/home/izero/devel/my_project/myproject/myproject/scripts/initializecdb.py", line 88, in main
create_schema(settings['mc_app_name'],log)
File "/home/izero/devel/my_project/myproject/myproject/cmodels/migrations/__init__.py", line 109, in create_schema
createMigrationTable(keyspace,log)
File "/home/izero/devel/my_project/myproject/myproject/cmodels/migrations/__init__.py", line 117, in createMigrationTable
sync_table(MigrationTable)
File "/home/izero/devel/my_project/my_project_env/lib/python3.4/site-packages/cassandra/cqlengine/management.py", line 135, in sync_table
cf_name = model.column_family_name()
File "/home/izero/devel/my_project/my_project_env/lib/python3.4/site-packages/cassandra/cqlengine/models.py", line 483, in column_family_name
return '{0}.{1}'.format(protect_name(cls._get_keyspace()), cf_name)
File "cassandra/metadata.py", line 1226, in cassandra.metadata.protect_name (cassandra/metadata.c:27387)
File "cassandra/metadata.py", line 1260, in cassandra.metadata.maybe_escape_name (cassandra/metadata.c:28214)
File "cassandra/metadata.py", line 1264, in cassandra.metadata.escape_name (cassandra/metadata.c:28294)
AttributeError: 'NoneType' object has no attribute 'replace'
Srikanth Bemineni