Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install gocept.rdbmanagement

How to install gocept.rdbmanagement

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install gocept.rdbmanagement
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.2 Available View build log
Windows (64-bit)
0.1.2 Available View build log
Mac OS X (10.5+)
0.1.2 Available View build log
Linux (32-bit)
0.1.2 Available View build log
Linux (64-bit)
0.1.2 Available View build log
 
License
ZPL 2.1
Lastest release
version 0.1.2 on Jan 5th, 2011

This is a zc.buildout recipe that helps managing schema updates on relational databases.

It currently only supports PostgreSQL.

Defining a managed database

A managed database has to be created (CREATEDB) outside of this recipe. The recipe only takes care of initialising an existing database and upgrading the schema subsequently.

Part definitions look like:

[managed_db]

System Message: ERROR/3 (<string>, line 20)

Inconsistent literal block quoting.

recipe = gocept.rdbmanagement dbname = mydatabase eggs = projectegg schema = projectegg.schemadir

host = localhost user = username password = apassword # XXX not implemented, not given

Where

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

Managed schema directories

A schema directory contains a set of SQL and Python files that are used to manage the schema for a database. A typical directory looks like this:

$ ls schemadir

System Message: ERROR/3 (<string>, line 48)

Inconsistent literal block quoting.

__init__.py init.sql precondition3.py update1.sql update2.sql update3.sql

Notice: A managed schema directory has to be a Python package.

init.sql
  • Creates the schema beginning from an empty database.
  • After init.sql the current generation will be set to the highest generation

System Message: WARNING/2 (<string>, line 63)

Bullet list ends without a blank line; unexpected unindent.

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

System Message: WARNING/2 (<string>, line 70)

Bullet list ends without a blank line; unexpected unindent.

statement.

  • Update script X will be run from a database at generation X-1.
preconditionX.py
  • Script must contain a function called precondition which takes one

System Message: WARNING/2 (<string>, line 78)

Bullet list ends without a blank line; unexpected unindent.

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

System Message: WARNING/2 (<string>, line 83)

Bullet list ends without a blank line; unexpected unindent.

database MUST not be updated to generation X.

Changes

0.1.2
  • allow newer versions than exactely psycopg==2.0.6
0.1.1
  • first public release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.