Morabaraba / python-liquibase

python wrapper for liquibase.jar and extra functions for easy py integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Liquibase

Home brewed wrapper library to make liquibase callable from python in the same vein as python-closure with an extension or two.

git clone python-liquibase
cd python-liquibase
pip install -e .
./get-liquibase.sh
./get-postgresql.sh # or ./get-mysql.sh
python -m liquibase # or `liquibase-run` as created by setup.py

But the extra sauce is in the Extentions.

Presentation

For some basic reasoning and example of usage see the Google Docs Presentation at the end there is also a Northwind continuous integration example.

Extentions

liquibase.ext.diff and liquibase.ext.update contain helper functions to use diffChangeLog and updateSQL more easily.

if you setup your liquibase/config.py via cp liquibase/config.py.pgsql.example liquibase/config.py or creating the file as seen below:

LIQUIBASE = {
	'url' : 'jdbc:postgresql://localhost:5432/WORKING_DATABASE_WE_WANT_TO_CHANGE',
	'driver' : 'org.postgresql.Driver',
	'classpath' : 'postgresql.jar',
	'username' : 'postgresql',
	'password' : '',
	
	# Required Diff Parameters
	'referenceUsername' : 'postgresql',
	'referencePassword' : '',
	'referenceUrl' : 'jdbc:postgresql://localhost:5432/EXAMPLE_DATABASE_WITH_LATEST_DDL',
}

After creation execute python liquibase/test.py or liquibase-ext-changelog-sql and if all went well a autogenerated SQL Update Database Script will be dumped to stdout.

This SQL script will update WORKING_DATABASE_WE_WANT_TO_CHANGE to match EXAMPLE_DATABASE_WITH_LATEST_DDL.

WARNING there might be DROP statements so review the SQL before just running it on your live database.

Note referenceDriver is commented out. You should be able to compare database across different db technology; your millage my vary.

Finally remember to read THE PROBLEM WITH DATABASE DIFFS.

Version Numbering

Will use the liquibase version number currently 3.5.3 and post-fix the date of the python package eg 3.5.3.180312.

Naming Convention and Python 2 Support

This is a helper library so I just decided on some names and ran with it. If you like the idea but disagree with the layout or structure create an issue.

Personally I would like to merge with one of the py-liquibase modules on pip. But I needed this today.

I'm lucky to only use py3. If this library does not work on py2 please create a pull request.

Thanks

Thanks to /u/nvoxland and other liquibase contributors without his work and contribution my little toy project will have no existence; and /u/miracle2k who's code I used as a base for this library.

License

Apache License 2.0

About

python wrapper for liquibase.jar and extra functions for easy py integration.


Languages

Language:Python 80.9%Language:Shell 19.1%