如何在 Python 中为现有 Cassandra 表创建 Table 对象?
我在键空间中有一些表,我想在 python DataStax 驱动程序中像 ORM 一样进行查询,
我有很多具有巨大架构的表。无需编写 Table 类即可创建表对象的任何其他方法,
例如: 如果我有一个名为 test_table 的表 那么
table_object =表(表名,元数据,自动加载= True)
I have some tables in a keyspace and I want query like ORM in python DataStax driver
I have lots of tables with huge schema. any other method to create a table object without writing the Table class
eg:
if I have a table called test_table
then
table_object=Table(table_name,metadata,autoload=True)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有提供太多信息,所以我不太确定您想要什么。无论如何,您可能对 Python 驱动程序中的模型感兴趣。
以下是类
Person
: 的文档示例,该类映射到此 CQL 表:
然后,您可以使用
Person
对象在表上执行 CRUD 操作。有关详细信息和更多示例,请参阅具有 Cassandra Python 驱动程序的模型。干杯!
You haven't provided a lot of information so I'm not really sure what you're after. In any case, you might be interested in Models in the Python driver.
Here's an example from the docs for a class
Person
:which maps to this CQL table:
You can then perform CRUD operations on the table using the
Person
object.For details and more examples, see Models with the Cassandra Python driver. Cheers!
我使用这个函数在 pyspark 中获取 Cassandra 表对象
I used this function for getting Cassandra table object in pyspark