ismailsimsek / pyliquibase

Python wrapper for liquibase.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License contributions welcome Python package

pyliquibase

Use liquibase with python. Java integration is done using Java Native Interface (JNI) using pyjnius

MariaDB/MySQL, MSSQL, PostgreSQL, SQLite, H2, HSQLDB, Snowflake, Bigquery, Redshift JDBC Drivers included.

Installation

install:

pip install pyliquibase

install from github:

pip install https://github.com/memiiso/pyliquibase/archive/master.zip --upgrade --user

How to Use

using command line:

pyliquibase --defaultsFile=changelogs/liquibase.properties status
pyliquibase --defaultsFile=changelogs/liquibase.properties validate
pyliquibase --defaultsFile=changelogs/liquibase.properties updateSQL
pyliquibase --defaultsFile=changelogs/liquibase.properties update

using python:

from pyliquibase import Pyliquibase
if __name__ == '__main__':
    liquibase = Pyliquibase(defaultsFile="changelogs/liquibase.properties", logLevel="INFO")
    # call execute with arguments
    liquibase.execute("status")
    liquibase.execute("rollback", "MyTag")
    # or 
    liquibase.validate()
    liquibase.status()
    liquibase.updateSQL()
    liquibase.update()
    liquibase.update_to_tag("MyTag")
    liquibase.rollback("MyTag")
    # liquibase maintenance commands
    liquibase.changelog_sync()
    liquibase.changelog_sync_to_tag("MyTag")
    liquibase.clear_checksums()
    liquibase.release_locks()

Python Java Integration

Python library is using LiquibaseCommandLine reflection class which uses/equivalent LiquibaseCommandLine java class. liquibase calls are executed by LiquibaseCommandLine.execute(liquibaseargs) method by passing given python arguments to java class.

python java integration class using pyjnius(using the Java Native Interface (JNI))

class LiquibaseCommandLine(JavaClass, metaclass=MetaJavaClass):
    __javaclass__ = 'liquibase/integration/commandline/LiquibaseCommandLine'
    # methods
    execute = JavaMethod('([Ljava/lang/String;)I')

Contributors

LIQUIBASE is a registered trademark of Liquibase , INC.

About

Python wrapper for liquibase.

License:Apache License 2.0


Languages

Language:Python 84.3%Language:Shell 15.7%