Skip to content

ROBelgium/msnoise-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSNoise-DB CLI Tool

This is a Python-based command-line interface (CLI) tool for managing a portable MariaDB server for MSNoise. The tool allows you to download, extract, install, start, stop, create, and drop databases using MariaDB.

MariaDB: Github Action Status Github Action Status

PostgreSQL: Github Action Status Github Action Status

Features

  • Download and extract MariaDB portable version.
  • Install/Setup MariaDB.
  • Start MariaDB server in the background.
  • Stop MariaDB server.
  • Create a new database.
  • Drop an existing database.
  • Supports custom configurations for port, maximum connections, and large queries.

Prerequisites

  • Python 3.10 or above.
  • click package: Install using pip install click.
  • requests package: Install using pip install requests.
  • psutil package: Install using pip install psutil.
  • configobj package: Install using pip install configobj.
  • pooch package: Install using pip install pooch.

Installation

  1. Clone the repository:

    git clone https://github.com/ROBelgium/msnoise-db.git
    cd msnoise-db
  2. Install the required Python packages:

    pip install click requests psutil configobj pooch
  3. Install this package:

    pip install -e .

Usage

1. Download and Extract MariaDB

Download and extract MariaDB portable version from a given URL.

msnoisedb download-and-extract C:/path/to/extract/to

2. Install MariaDB

Install MariaDB by specifying the port (default is 3307).

msnoisedb install-db

3. Start MariaDB Server

Start the MariaDB server in the background.

msnoisedb start-server

4. Stop MariaDB Server

Stop the running MariaDB server.

msnoisedb stop-server

5. Create a New Database

Create a new database.

msnoisedb create-database DATABASE_NAME

6. Drop an Existing Database

Drop an existing database.

msnoisedb drop-database DATABASE_NAME

Environment Variable

You should set the MARIADB_DIR environment variable to the path where MariaDB is extracted. This avoids passing the directory path as an argument to each command.

Similarly, if you plan to use another port than the default (3307), you can set the MARIADB_PORT environment variable.

On Windows:

set MARIADB_DIR=C:\path\to\extracted\mariadb
set MARIADB_PORT=9307

On Linux/macOS:

export MARIADB_DIR=/path/to/extracted/mariadb
export MARIADB_PORT=9307

Configuration

The tool makes use of a custom configuration file named my_custom.cnf to manage the MariaDB server settings. The configuration file includes settings such as:

  • Port number
  • skip-grant-tables to allow any user to connect without a password.
  • max_connections to allow more than the default 10 connections.
  • max_allowed_packet to allow large query sizes.

Example Configuration (my_custom.cnf)

[mysqld]
port=3307
skip-grant-tables
max_connections=100
max_allowed_packet=64M

Notes

  • Security Warning: The skip-grant-tables option is included for development and debugging purposes, allowing any user to connect without authentication. This should not be used in a production environment.
  • Supported Platforms: The tool is designed to work on both Windows and Linux platforms.

License

This project is licensed under the EUPL License. See the LICENSE file for more details.

Acknowledgements

  • Click for creating powerful command-line interfaces.
  • Requests for handling HTTP requests.
  • Psutil for process management.
  • ConfigObj for reading and writing configuration files.
  • Pooch for downloading the portable zip/tarball.