diff --git a/README.md b/README.md index 27af8fb..8d2075b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ [![License](http://img.shields.io/:license-apache%202.0-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) -![Python package](https://github.com/memiiso/pyliquibase/workflows/Python%20package/badge.svg) - +[![Create Pypi Release](https://github.com/memiiso/pyliquibase/actions/workflows/release.yml/badge.svg)](https://github.com/memiiso/pyliquibase/actions/workflows/release.yml) # pyliquibase -Use [liquibase](http://www.liquibase.org/) with python. Java integration is done using Java Native Interface (JNI) using [pyjnius](https://github.com/kivy/pyjnius) +A Python module to use [liquibase](http://www.liquibase.org/) in python, using the Java Native Interface (JNI). -MariaDB/MySQL, MSSQL, PostgreSQL, SQLite, H2, HSQLDB, Snowflake, Bigquery, Redshift JDBC Drivers included. +For further details on python-java integration [please see here](#python-java-integration) ## Installation @@ -33,6 +32,7 @@ pyliquibase --defaultsFile=changelogs/liquibase.properties update using python: ```python from pyliquibase import Pyliquibase + if __name__ == '__main__': liquibase = Pyliquibase(defaultsFile="changelogs/liquibase.properties", logLevel="INFO") # call execute with arguments @@ -53,10 +53,11 @@ if __name__ == '__main__': ``` ## 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)) +Python library is based on `LiquibaseCommandLine` Python class. It is reflection of Java `LiquibaseCommandLine` class. +liquibase calls are passed to Java `LiquibaseCommandLine.execute(liquibaseargs)` method. + +[Pyjnius](https://github.com/kivy/pyjnius) is a Python library for accessing Java classes. It either starts a new JVM inside the process, or retrieves the already surrounding JVM. To read more on pyjnius please see https://pyjnius.readthedocs.io/en/latest/ ```python class LiquibaseCommandLine(JavaClass, metaclass=MetaJavaClass): __javaclass__ = 'liquibase/integration/commandline/LiquibaseCommandLine' diff --git a/pyliquibase/__init__.py b/pyliquibase/__init__.py index 6e57ed0..7d88691 100644 --- a/pyliquibase/__init__.py +++ b/pyliquibase/__init__.py @@ -46,6 +46,14 @@ def __init__(self, defaultsFile: str, :param additionalClasspath: additional classpath to import java libraries and liquibase extensions """ + # if liquibaseDir is provided then switch to user provided liquibase. + if liquibaseDir: + self.liquibase_dir: str = liquibaseDir.rstrip("/") + self.version: str = "user-provided" + else: + self.version: str = version + self.liquibase_dir: str = resource_filename(__package__, LIQUIBASE_DIR.format(self.version)) + self.args = [] if defaultsFile: if not pathlib.Path.cwd().joinpath(defaultsFile).is_file() and not pathlib.Path(defaultsFile).is_file(): @@ -53,7 +61,7 @@ def __init__(self, defaultsFile: str, self.args.append("--defaults-file=%s" % defaultsFile) - if liquibaseHubMode: + if liquibaseHubMode and self.version < "4.22.0": self.args.append("--hub-mode=%s" % liquibaseHubMode) if logLevel: @@ -61,14 +69,6 @@ def __init__(self, defaultsFile: str, self.additional_classpath: str = additionalClasspath.rstrip('/') if additionalClasspath else None - # if liquibaseDir is provided then switch to user provided liquibase. - if liquibaseDir: - self.liquibase_dir: str = liquibaseDir.rstrip("/") - self.version: str = "user-provided" - else: - self.version: str = version - self.liquibase_dir: str = resource_filename(__package__, LIQUIBASE_DIR.format(self.version)) - # if jdbcDriversDir is provided then use user provided jdbc driver libraries self.jdbc_drivers_dir: str = jdbcDriversDir.rstrip("/") if jdbcDriversDir else None self.liquibase_lib_dir: str = self.liquibase_dir + "/lib" diff --git a/setup.py b/setup.py index 926f3d3..b37f13c 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,6 @@ include_package_data=True, license="Apache License 2.0", test_suite='tests', - install_requires=["pyjnius~=1.6.0"], + install_requires=["pyjnius~=1.6.1"], python_requires='>=3.8', ) diff --git a/tests/test_pyliquibase_version.sh b/tests/test_pyliquibase_version.sh index c3ca22c..732f365 100644 --- a/tests/test_pyliquibase_version.sh +++ b/tests/test_pyliquibase_version.sh @@ -2,7 +2,7 @@ set -e -declare -a lbVersionList=("4.9.0" "4.10.0" "4.11.0") +declare -a lbVersionList=("4.9.0" "4.10.0" "4.11.0" "4.21.1" "4.23.2" "4.24.0") for version in "${lbVersionList[@]}"; do export TEST_LIQUIBASE_VERSION=$version echo "Testing TEST_LIQUIBASE_VERSION ${TEST_LIQUIBASE_VERSION}"