Skip to main content

Xalanih is a python script made to help you version your SQL database.

Project description

What is Xalanih ?

Xalanih is a python script made to help you version your SQL database. You can use it to manage the creation or update the database of your project.

Technical Requirements

  • Python 3.6
  • mysqlclient
  • sqlparse

How to install Xalanih

pip3 install xalanih

How to use Xalanih

Create the db

python3 -m xalanih create <database>

where <database> must be replaced by the name of the database.

Update the db

python3 -m xalanih update <database>

where <database> must be replaced by the name of the database.

Options

Differents options can be given to the script. You can find all of them using the following command:

python3 xalanih -h

Working directory

-d <directory>

Specify the directory where all the database scripts are.

Default value: "."

Database type

-t <type>

Specify the type of database to which the script has to connect.

Accepted value: mysql | Default value: mysql

Host

-H <host>

The address of the host of the database.

Default value: localhost

Port

-p <port>

The port of the database.

Default value: 3306

User

-u <user>

The user used to connect

Default value: root

Password

-pwd <password>

The password used to connect to the database.

Socket

-s <socket>

The path to the mysql socket if it is not at the default location (/tmp/mysql.sock).

Logging

These options are linked to the logging.

Verbosity

-v <verbosity>

The verbosity of the logs in standard output.

Accepted values: 0,1,2,3,4 | Default value: 3

  • 0: No logs.
  • 1: Only errors.
  • 2: Errors and warnings.
  • 3: Informations, warnings and errors.
  • 4: Debugs, informations, warnings and errors.

Log file

-l <filename>

The name of the file where the logs are saved. It is not affected by the verbosity options (It is always set at 4). If no file specified, no file are created.

last update

-to <update>

Define the last update that will be applied. Must be an update not included in included_updates.

no update

-nu

Has only an effect with the create option. If specified, the script will only execute the creation script and will not apply the updates.

How to structure the directory containing the database scripts

The structure to use for the directory that contains all the scripts you have for your database.

L creation (directory)
    L  creation.sql (file)
    L  included_updates (file)
L update (directory)
    L  script01.sql (file)
    L  ...

creation (directory)

The creation directory will contains the scripts that will be used to create the baseline of the database. These will only be called when the database is created from zero. That means that they will not be used in case of a database update.

creation.sql (file)

The script creation.sql is the entrypoint of Xalanih to create the database. This file must contains all the needed script to create the baseline of your database.

included_updates (file)

When you will have a lot of update file, you will want to create the database directly with these modification instead of applying them after. In order to do that, you will have to add the modification directly to your creation.sql. But in order for Xalanih to not apply the update scripts, you have to add the name of all update scripts already integrated to the file included_updates. There should be one filename by line.

update (directory)

The update directory must contains all your update scripts (and nothing else). There is not realy a nomenclature for the update scripts but the alphabetical order should correspond to their chronological order. Also, no patch can be named initial_install. This is because this name is associated to the creation of the database

Table created by xalanih: xalanih_updates

The table xalanih_patches contains 3 columns: id, update_name, and update_apply_time. It is used by the script to detect which patches have already been applied. The patch name associated to the initial creation of the database is initial_install.

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

xalanih-1.0.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

xalanih-1.0.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file xalanih-1.0.0.tar.gz.

File metadata

  • Download URL: xalanih-1.0.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xalanih-1.0.0.tar.gz
Algorithm Hash digest
SHA256 288e52925af6d5dfe959b4f572d410f1357d3f422ee48fe8071fb0e26cd63d39
MD5 807a45316f72266d9384d5acedb083ee
BLAKE2b-256 bc9509f112ab19009148999794e47af53efe0caaa74d1bf409fca02368150670

See more details on using hashes here.

File details

Details for the file xalanih-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xalanih-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a4ccaa4f5624e9252639cf6ab7a06b2f58a4b3b75e0c929f1098910c5731d20
MD5 794ca7f47cb1f4c1cf564df7fc2fc9fe
BLAKE2b-256 8e01e6db2b4bcfdd9b3e0c245ccd931d5ae1c98e88a9c2f4d63b5ddccfebdc28

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