<i id='2I9e1'><tr id='2I9e1'><dt id='2I9e1'><q id='2I9e1'><span id='2I9e1'><b id='2I9e1'><form id='2I9e1'><ins id='2I9e1'></ins><ul id='2I9e1'></ul><sub id='2I9e1'></sub></form><legend id='2I9e1'></legend><bdo id='2I9e1'><pre id='2I9e1'><center id='2I9e1'></center></pre></bdo></b><th id='2I9e1'></th></span></q></dt></tr></i><div id='2I9e1'><tfoot id='2I9e1'></tfoot><dl id='2I9e1'><fieldset id='2I9e1'></fieldset></dl></div>
  • <small id='2I9e1'></small><noframes id='2I9e1'>

      <bdo id='2I9e1'></bdo><ul id='2I9e1'></ul>
  • <legend id='2I9e1'><style id='2I9e1'><dir id='2I9e1'><q id='2I9e1'></q></dir></style></legend>

    1. <tfoot id='2I9e1'></tfoot>
      1. 是否值得使用 sqlalchemy-migrate ?

        时间:2023-10-20

          <i id='VkVwN'><tr id='VkVwN'><dt id='VkVwN'><q id='VkVwN'><span id='VkVwN'><b id='VkVwN'><form id='VkVwN'><ins id='VkVwN'></ins><ul id='VkVwN'></ul><sub id='VkVwN'></sub></form><legend id='VkVwN'></legend><bdo id='VkVwN'><pre id='VkVwN'><center id='VkVwN'></center></pre></bdo></b><th id='VkVwN'></th></span></q></dt></tr></i><div id='VkVwN'><tfoot id='VkVwN'></tfoot><dl id='VkVwN'><fieldset id='VkVwN'></fieldset></dl></div>
          • <tfoot id='VkVwN'></tfoot>
              <bdo id='VkVwN'></bdo><ul id='VkVwN'></ul>
              <legend id='VkVwN'><style id='VkVwN'><dir id='VkVwN'><q id='VkVwN'></q></dir></style></legend>

                <tbody id='VkVwN'></tbody>

                  <small id='VkVwN'></small><noframes id='VkVwN'>

                  本文介绍了是否值得使用 sqlalchemy-migrate ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个使用 sqlalchemy(在 Pylons 内)的 Web 应用程序.我需要有效地更改架构,以便能够至少每天更改生产版本,也许更多,而不会丢失数据.

                  I have a web application using sqlalchemy (within Pylons). I need to effiently change the schema to be able to change the production version at least on a daily basis, maybe more, without losing the data.

                  我在周末玩了一点 sqlalchemy-migrate,我想说它给我留下了不好的印象.首先我认为这无助于两个数据库引擎之间的迁移;这可能只用 sqlalchemy 就可以完成.其次,文档似乎不是最新的.我不得不更改一些命令行选项,例如在每个命令中提供存储库路径,这可能是迁移的错误.

                  I have played a little bit with sqlalchemy-migrate over the week-end and I would say that it gave me a bad impression. First I think it cannot help with migration between two databases engines; that's something that could probably be done with sqlalchemy alone. Second the docs do not seem up to date. I had to change some command-line options, like giving the repository path at each command, this could be a bug of migrate.

                  但最糟糕的是manage.py test"命令.不仅它实际上修改了数据库(这一点在文档中明确指出,所以我不能责怪迁移)而且我的第一个迁移脚本只是进行了简单愚蠢的模式迁移,使升级降级的数据库与与原始架构不同的架构.但是manage.py 测试"只是回答了类似

                  But the worst thing it the "manage.py test" command. Not only it actually modifies the database (this point is clearly indicated in the documentation so I can't blame migrate) but my first migration script just made plain stupid schema migration, leaving the upgraded-downgraded db with a different schema than the original. But the "manage.py test" just answered something like

                   success !
                  

                  也就是说,它甚至不检查模式是否保持一致状态.那么值得使用迁移吗?与与良好实践相关的自己动手"方法相比有什么优势 ?是否有 sqlalchemy-migrate 的替代方法实际上简化了迁移过程,或者我只是尝试使用带有错误的迁移 priori (然后请告诉我为什么明显优于创建 CSV 列,如上面的链接)?

                  That is, it did not even check if the schema was left in a coherent state. So is it worth using migrate? Is there any advantage compared to the Do It Yourself method associated with good practices as proposed by S.Lott ? Are there alternatives to sqlalchemy-migrate actually simplifying the migration process or am I just trying to use migrate with a bad a priori (then please show me why is't clearly superior to creating CSV columns as proposed in the link above)?

                  非常感谢!

                  推荐答案

                  改用 Alembic:

                  Use Alembic instead:

                  http://pypi.python.org/pypi/alembic

                  感谢您的评论,编辑添加一些推理--

                  Thanks for comments, edited to add some reasoning --

                  它是由 SQLAlchemy 的作者开发的,它是全新的并且得到很好的支持.我对 sqlalchemy-migrate 的了解还不够,无法进行很好的比较.但我快速阅读了清晰简洁的 Alembic 文档,然后在很短的时间内完成了我自己的自动生成迁移.

                  It's developed by the author of SQLAlchemy, and it's brand new and well supported. I don't know enough about sqlalchemy-migrate to give a good comparison. But I took a quick read through the clear and concise Alembic docs, then got my own autogenerated migration working in a very short time.

                  自动生成:不是它唯一的操作模式,但如果您选择,Alembic 将读取您应用程序的 sqlalchemy 配置(例如,设置所有表、约束和映射的声明性模型类)并与实际当前数据库的状态,并输出一个 Python 脚本来表示两者之间的差异.然后将该脚本传递给 Alembic 的升级命令,然后就可以解决差异了.通常需要手动编辑少量的迁移脚本,这是 (a) 只是迁移的性质,以及 (b) 无论如何您都想做的事情,以确保您完全了解迁移的确切步骤在运行之前执行.

                  Autogeneration: Not its only mode of operation, but if you choose, Alembic will read your application's sqlalchemy configuration (for instance, your declarative model classes that set up all your tables, constraints, and mappings) and compare to the actual current state of your database, and output a Python script that represents the delta between the two. You then pass that script to Alembic's upgrade command and there you go, the differences are resolved. A small amount of editing the migration script by hand is usually needed, and that's (a) just the nature of migrations, and (b) something you want to do anyway to make sure you were fully aware of the exact steps that the migration is going to perform before you run it.

                  Alembic 也为您的迁移跟踪方式带来了类似 DVCS 的功能.它可以很容易地返回到您的数据库架构的任何过去状态.

                  Alembic brings a DVCS-like ability to the way your migrations are tracked, too. It makes it really easy to return to any past state of your db schema.

                  这篇关于是否值得使用 sqlalchemy-migrate ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:django 迁移 - 具有多个开发分支的工作流 下一篇:Django - South - 有没有办法查看它运行的 SQL?

                  相关文章

                1. <i id='riRdv'><tr id='riRdv'><dt id='riRdv'><q id='riRdv'><span id='riRdv'><b id='riRdv'><form id='riRdv'><ins id='riRdv'></ins><ul id='riRdv'></ul><sub id='riRdv'></sub></form><legend id='riRdv'></legend><bdo id='riRdv'><pre id='riRdv'><center id='riRdv'></center></pre></bdo></b><th id='riRdv'></th></span></q></dt></tr></i><div id='riRdv'><tfoot id='riRdv'></tfoot><dl id='riRdv'><fieldset id='riRdv'></fieldset></dl></div>
                  <legend id='riRdv'><style id='riRdv'><dir id='riRdv'><q id='riRdv'></q></dir></style></legend>

                2. <tfoot id='riRdv'></tfoot>

                    <small id='riRdv'></small><noframes id='riRdv'>

                      <bdo id='riRdv'></bdo><ul id='riRdv'></ul>