我可以从pynamodb中的tableconnection创建模型吗?
我有通过基础结构-AS代码实现创建的现有DynamoDB表。
在我的应用程序中,我想为此现有表使用模型
抽象。
我使用tableConnection
连接到现有表并运行较低级别命令(get_item
等)。
有没有一种方法可以从现有tableconnection
中创建模型
(不重新定义model
)?
这样的事情:
table = TableConnection('ExistingTable')
ExistingTable = Model.create_model_from_existing(table) # made up method
new_item = ExistingTable('hash key', 'sort key')
new_item.save()
I have existing DynamoDB tables created through an infrastructure-as-code implementation.
Within my application I would like to use the Model
abstraction for this existing table.
I used TableConnection
to connect to the existing table and run the lower level commands (get_item
etc.).
Is there a way to create a Model
from an existing TableConnection
(without redefining the Model
)?
Something like this:
table = TableConnection('ExistingTable')
ExistingTable = Model.create_model_from_existing(table) # made up method
new_item = ExistingTable('hash key', 'sort key')
new_item.save()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,没有方法可以这样做。
您将必须手动创建
模型
。No unfortunately, there’s no method to do that.
You will have to create the
Model
manually.