Package: xalanih
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 RequirementsPython 3.6mysqlclientsqlparseHow to install Xalanihpip3 install xalanihHow to use XalanihCreate the dbpython3-mxalanihcreate<database>where <database> must be replaced by the name of the database.Update the dbpython3-mxalanihupdate<database>where <database> must be replaced by the name of the database.OptionsDifferents options can be given to the script. You can find all of them using the following command:python3 xalanih -hWorking 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: mysqlHost-H <host>The address of the host of the database.Default value: localhostPort-p <port>The port of the database.Default value: 3306User-u <user>The user used to connectDefault value: rootPassword-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).LoggingThese 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: 30: 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 inincluded_updates.no update-nuHas 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 scriptsThe 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)Thecreationdirectory 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 scriptcreation.sqlis 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 yourcreation.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 fileincluded_updates. There should be one filename by line.update(directory)Theupdatedirectory 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 namedinitial_install. This is because this name is associated to the creation of the databaseTable created by xalanih: xalanih_updatesThe 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 isinitial_install.