我是新来的cassandra-driver==3.25.0
。我已经创建了一个模型Model
并尝试同步它。问题:
- 我打电话
sync_table
- 我看到表开始在 Keyspaces 中创建并且定义是正确的
- 但是从这行代码中
sync_table
引发了一个异常KeyError {__table_name__}
table = cluster.metadata.keyspaces[ks_name].tables[raw_cf_name]
- 我可以
sync_table
再次打电话,一段时间后它工作正常
所以我假设它可能会从 Keyspaces 延迟,所以cassandra-driver
在同步表上有某种等待,或者你能指出文档吗?
class Users(Model):
__keyspace__ = 'aura'
__table_name__ = 'users'
__connection__ = 'aws_keyspace'
user_id = columns.UUID(primary_key=True)
tags = columns.Map(key_type=columns.Text(), value_type=columns.Text())
cluster = Cluster(...)
session = cluster.connect()
connection.register_connection('aws_keyspace', session=session, default=True)
sync_table(Users)
完全例外:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "models.py", line 69, in <module>
sync_table(AttachmentsByUsers)
File "python3.6/site-packages/cassandra/cqlengine/management.py", line 190, in sync_table
_sync_table(m, connection=connection)
File "python3.6/site-packages/cassandra/cqlengine/management.py", line 274, in _sync_table
table = cluster.metadata.keyspaces[ks_name].tables[raw_cf_name]
KeyError: 'users'