如何将Sqlalchemy Orm与Sqlalchemy迁移?
当我决定将版本的跟踪对DB架构实现时,我正在使用SQLalchemy Orm连接到内存数据库。为此,我一直在关注有关如何设置使用SQLalchemy 版本控制,但是现在我想知道是否有一种方法可以让我升级和降级脚本也可以更新/创建我的sqlalchemy.orm表?
我之所以问这个,是因为我现在不知道如何仅使用SQLalchemy迁移编写代码,因为开发人员可能不知道数据库所做的最新更改。当前,开发人员只需要查看包含映射到DB表格的类的文件即可知道可用的内容,但是从我的理解中,使用迁移将不会将这些类与升级/降级脚本中应用的更改同步。此同步需要手动完成。我看了反思,但这似乎并不需要有关表结构的先验知识。
我知道我一定会缺少一些东西。每当我的内存都想在DB中确认某些内容时注意:我的阅读障碍很严重,我倾向于许多拼写错误,这就是为什么我完全完整地彻底提高了我的生产力的原因)。升级脚本可以创建/更新/删除包含ORM类的文件吗?
IE。
class ExtractionEvent(Base):
__tablename__ = 'ExtractionEvents'
Id = Column(Integer, primary_key=True, autoincrement=True)
...
I was using SQLAlchemy ORM to connect to a in memory database when I decided to implement a versioning tracking to the DB schema. To do this I've been following the tutorial on how to set up Versioning using SQLAlchemy, but now I'm wondering if there is a way for me to get my upgrade and downgrade scripts to also update/create my SQLAlchemy.orm tables?
I ask this because I now don't know how to write code using only SQLAlchemy Migrate since a developer might not know of the most recent change done to the database. Currently the developer just has to look at the file containing the class that maps to a table in the DB to know what is available, but from my understanding using Migrate would not synchronize these classes with the changes applied in a upgrade/downgrade script. This synchronization would need to be done manually. I looked at reflect but this doesn't seem to require prior knowledge as to the structure of the table.
I know I must be missing something. I could have my DB opened in HeidiSQL and [ALT + TAB] each time my memory wants to confirm something in the DB but this is slows me down a lot when I used to just be able to use auto complete on classes as I type (Note: I'm heavily dyslexic and I'm prone to many spelling mistakes which is why I auto complete drastically improves my productivity). Is there a way for the upgrade scripts to create/update/delete files containing ORM classes?
ie.
class ExtractionEvent(Base):
__tablename__ = 'ExtractionEvents'
Id = Column(Integer, primary_key=True, autoincrement=True)
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论