Skip to main content

Recipe for managing RDB schemas

Project description

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]
recipe = gocept.rdbmanagement
dbname = mydatabase
eggs = projectegg
schema = projectegg.schemadir

host = localhost
user = username
password = apassword

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
__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 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.

preconditionX.py

  • Script must contain a function called precondition 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.

Changes

1.1 (2020-04-15)

  • Support Python 3.

1.0 (2015-07-06)

  • Implement ability to use a password when accessing the database, requiring at least PostgreSQL 9.0 for this feature.

  • Require at least Python 2.7.

0.1.2

  • allow newer versions than exactely psycopg2==2.0.6

0.1.1

  • first public release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gocept.rdbmanagement-1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

gocept.rdbmanagement-1.1-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file gocept.rdbmanagement-1.1.tar.gz.

File metadata

  • Download URL: gocept.rdbmanagement-1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for gocept.rdbmanagement-1.1.tar.gz
Algorithm Hash digest
SHA256 3b5b694ffeefd09b5bec8769e8ce1c3b31ed3a431abb9d9987038cce538c4192
MD5 4d85026fefbc469135a49a5f95b3467e
BLAKE2b-256 ec107028e51ee36e0444a21862d25ab6ef7006964d072641c0ccaf3ba13d8011

See more details on using hashes here.

File details

Details for the file gocept.rdbmanagement-1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: gocept.rdbmanagement-1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for gocept.rdbmanagement-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e27bb745e3d9d10e60605b9425d9778d64477ff2fd820fe96c583adc71976f0
MD5 90d4f75a5b426f180d99fed3da6b0db8
BLAKE2b-256 380cae0f0e2c6b66514ef3658d20117f7c88e1f8b98d3e6b4d53396e39c48aa6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page