我可以从pynamodb中的tableconnection创建模型吗?

发布于 2025-01-31 21:55:27 字数 480 浏览 3 评论 0原文

我有通过基础结构-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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2025-02-07 21:55:27

是否有一种方法可以从现有tableconnection中创建模型(不重新定义模型)?

不幸的是,没有方法可以这样做。

您将必须手动创建模型

Is there a way to create a Model from an existing TableConnection (without redefining the Model)?

No unfortunately, there’s no method to do that.

You will have to create the Model manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文