管理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第三方库


热门话题
HTTP标头的java InputStream未终止   java测试SpringWebListener   具有定义的替换编号Java的regex ReplaceAll   在java中使用contains()方法   java在选择查询中使用JoinColumn字段   具有用户的java Start-stop demon不是以给定用户启动   java glBufferData生成GL\u无效\u操作   java中循环代码的循环   Java位无符号移位(>>>>)会产生奇怪的结果   java HQL使用点分隔符从select获取结果   条纹、弹簧、玩耍(或?):使用哪种高性能Java框架?   广播接收机中的java停止服务   java回收器视图占据整个屏幕。不在上面显示我的UI元素   java使MySQL查询更快   java MappedByteBuffer查询   java递归算法问题