Skip to main content

a database migration tool

Project description

AQ-DBMigration

a db migration tool in python

home

github: nanshens/AQ-DBMigration

install

pip install aq-dbmigration

how to use

    config = MigrationConfig("db_name", "db_user", "db_password", "db_host", "db_port", DBConstant.Type.PostgreSQL, "db file path")
    db = DBMigration(config)
    db.migration()

if you want to skip migration, you can set skip is True in db.migration(), like this:

    db.migration(True)

sql file

file format: V{version}__{description}.sql
example: V1__test.sql, V2__issue1.sql, V2.1__issue11.sql, V2.12__issue12.sql

version: version = main sequence + . + sub sequence, so order by main first, then sub. example: V1.2 run first and V1.13 second, because 2 < 13.

please start from V1

MigrationConfig

file path

please use absolute path.
if you use flask, you can set db_path in flask config, like this app.config['DB_MIGRATION_PATH'] = os.path.join(app.root_path, 'resource', 'db_migration') and use MigrationConfig("db_name", "db_user", "db_password", "db_host", "db_port", DBConstant.Type.PostgreSQL, app.config['DB_MIGRATION_PATH']) to init

baseline

When used for the first time, it will set the baseline, and subsequent changes will not take effect.
Only read sql files larger than baseline.

database support

  1. postgresql(tested pass)
  2. mysql(in testing)
  3. maria(in testing)
  4. sqlite(in testing)

License

This project is licensed under the terms of the GNU General Public License v3.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aq_dbmigration-1.0.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

aq_dbmigration-1.0.2-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file aq_dbmigration-1.0.2.tar.gz.

File metadata

  • Download URL: aq_dbmigration-1.0.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for aq_dbmigration-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4382ac99910a922eeaddfc7a6f0c3ef7be501f6bcb3bf805c5171f817627fc98
MD5 999181b3e9be32941c0d2edfa8b490dc
BLAKE2b-256 5e31c1dd24dccd1aed7891daa6d0fcd7d5090c97655280030bc5f54c6f690532

See more details on using hashes here.

File details

Details for the file aq_dbmigration-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for aq_dbmigration-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb04a52461222bd9c2d7898aa60dd1275b67db29c1fd2ff25091ca8759e06750
MD5 8778e0facf52eb6dbf65587c4e830a1f
BLAKE2b-256 28128dde99fb658cc7b46e72b24aae4fd404a311cfaa18cbe689d9f550da470a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page