Skip to content

Commit

Permalink
Disable hub mode for new versions, Update pyjnius to 1.6.1 and improv…
Browse files Browse the repository at this point in the history
…e documentation (#74)

* Update documentation

* Update pyjnius to 1.6.1

* Add "4.21.1" "4.23.2" "4.24.0" "4.25.1" lb versions to testing list

* Disable hub mode argument for new versions >= "4.22.0"

* remove 2.25.x version from tests
  • Loading branch information
ismailsimsek authored Jan 7, 2024
1 parent fb8ce29 commit f903c8d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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'
Expand Down
18 changes: 9 additions & 9 deletions pyliquibase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ 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():
raise FileNotFoundError("defaultsFile not found! %s" % defaultsFile)

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:
self.args.append("--log-level=%s" % logLevel)

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"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
2 changes: 1 addition & 1 deletion tests/test_pyliquibase_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit f903c8d

Please sign in to comment.