管理rdb模式的诀窍

gocept.rdbmanagement的Python项目详细描述


这是一个zc.buildout配方,有助于管理关系模式更新 数据库

目前只支持PostgreSQL。

定义托管数据库

必须在此配方之外创建托管数据库(createDB)。这个 配方只负责初始化现有数据库并升级 架构随后。

零件定义如下:

[managed_db]
recipe = gocept.rdbmanagement
dbname = mydatabase
eggs = projectegg
schema = projectegg.schemadir

host = localhost
user = username
password = apassword

其中

dbname
is the name of the PostgreSQL database to work with
eggs
is a list of egg requirements that should be activated before looking up the schema directory resource path
schema
is a setuptools resource path that is a managed schema directory

托管架构目录

模式目录包含一组SQL和Python文件,这些文件用于 管理数据库的架构典型的目录如下:

$ ls schemadir
__init__.py
init.sql
precondition3.py
update1.sql
update2.sql
update3.sql

注意:托管模式目录必须是python包。

初始sql

  • Creates the schema beginning from an empty database.
  • After init.sql the current generation will be set to the highest generation number as available from the update scripts. Therefore the init.sql always creates a current database schema and no updates will be run.

updatex.sql

  • Update scripts MUST start with a BEGIN statement and end with a COMMIT statement.
  • Update script X will be run from a database at generation X-1.

前提条件x.py

  • Script must contain a function called ^{tt1}$ which takes one parameter which is an open DB-API2-connection to the database.
  • Precondition script X will be run on a database at generation X-1.
  • Precondition script X has to raise an exception to indicate that the database MUST not be updated to generation X.

变化

1.0(2015-07-06)

  • 实现访问数据库时使用密码的能力,要求 此功能的PostgreSQL 9.0最低版本。
  • 至少需要Python2.7

0.1.2

  • 允许比exactly psycopg2==2.0.6更高的版本

0.1.1

  • 首次公开发行

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Kafka producer大量内存使用(泄漏?)   java NullPointerException。。。正在插入数据但无法检索数据[Mysql DB]   java spring+jpa+hibernate=没有可用于当前线程的实际事务的EntityManager无法可靠地处理“persist”调用   getelementbyid在没有ID的情况下如何在java中使用GetElementsById   java有没有一种使用WatchService强制轮询的方法?   java将值从jframe传递给另一个jframe并使用它   Java/Groovy中带重试的反应式事件处理   具有两个包装器元素的java Jackson XML ArrayList输出   java总是在范围内使用不同的随机元素   取消选择java下拉列表值   多线程如何在Java中为对象的不同成员拥有不同的同步块   java如何使用多线程从文本文件中读取输入   java Spring启动附加崩溃命令   java使用公共或单独的actionPerfomed方法有什么区别   java用Spring3.0中的SpEL替换JSP中的EL   java作为windows服务运行应用程序时无法访问共享文件夹   java xml 1.1规范中的“解析数据”是什么意思?   以编程方式设置JComboBox索引时java触发ItemListener   java Android WebView:只加载HTML,不加载JS或CSS(在某些设备中)   Java:计算do/while循环的数量