https://github.com/memiiso/pyliquibase
Use liquibase java application within python
https://github.com/memiiso/pyliquibase
continuous-deployment database-change-management-tool database-management database-migrations liquibase postgresql python
Last synced: 24 days ago
JSON representation
Use liquibase java application within python
- Host: GitHub
- URL: https://github.com/memiiso/pyliquibase
- Owner: memiiso
- License: apache-2.0
- Created: 2020-01-04T16:15:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-21T10:57:14.000Z (2 months ago)
- Last Synced: 2025-03-28T07:06:53.583Z (about 1 month ago)
- Topics: continuous-deployment, database-change-management-tool, database-management, database-migrations, liquibase, postgresql, python
- Language: Python
- Homepage:
- Size: 190 MB
- Stars: 50
- Watchers: 3
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://www.apache.org/licenses/LICENSE-2.0.html)

[](https://github.com/memiiso/pyliquibase/actions/workflows/release.yml)
# pyliquibaseA Python module to use [liquibase](http://www.liquibase.org/) in python, using the Java Native Interface (JNI).
For further details on python-java integration [please see here](#python-java-integration)
## Installation
Python-Java integration requires a Java Development Kit (JDK). Ensure a JDK is installed on your operating system.install:
```shell
pip install pyliquibase
```## How to Use
using command line:
```shell
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:
```python
from pyliquibase import Pyliquibaseif __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
This Python library integrates with Java using the `LiquibaseCommandLine` class. Our Python `LiquibaseCommandLine` class acts as a reflection of the Java counterpart, passing Liquibase calls to the Java `LiquibaseCommandLine.execute(liquibaseargs)` method.
This integration leverages [Pyjnius](https://github.com/kivy/pyjnius), a Python library for accessing Java classes. Pyjnius either starts a new Java Virtual Machine (JVM) within the current process or connects to an existing JVM. For more information on Pyjnius, please refer to their documentation: https://pyjnius.readthedocs.io/en/latest/.
```python
class LiquibaseCommandLine(JavaClass, metaclass=MetaJavaClass):
__javaclass__ = 'liquibase/integration/commandline/LiquibaseCommandLine'
# methods
execute = JavaMethod('([Ljava/lang/String;)I')
```##
LIQUIBASE is a registered trademark of [Liquibase](https://www.liquibase.com) , INC.