Skip to main content

mysqld-integration-test is a python module that creates a temporary mysqld instance to use for testing your application.

Project description

mysqld-integration-test

Overview

mysqld-integration-test is a python module that creates a temporary mysqld instance to use for testing your application. It is based on the testing.mysqld module which has not been updated recently. You will need a working MySQL or MariaDB install. It does not have to be running, the binaries are needed.

Download and Install

To install use pip:

$ pip install mysqld-integration-test

Or clone the repo:

$ git clone https://github.com/jasondcamp/mysqld-integration-test.git

Configuration

Class arguments

The following class arguments can be overridden by passing them in, these arguments will override the config file arguments.

Argument Description Default
username Username for database root
password Password for database root
host Host to bind 127.0.0.1
port Port to bind random
mysql_install_db_binary Location of mysql_install_db Searches paths
mysqld_binary Location of mysqld Searches paths
timeout_start Timeout to start MySQL 30 seconds
timeout_stop Timeout to stop MySQL 30 seconds
log_level Log level INFO
config_file Configuration file mysqld-integration-test.cfg

mysqld-integration-test config file

Default settings can be overridden in a config file. The default name is mysqld-integration-test.cfg in the local directory and can be overridden by passing in the config option to the instance creation.

Example config

database:
  host: '127.0.0.1'
  port: '9999'
  username: 'root'
  password: 'test'
  mysql_install_db_binary: '/usr/local/bin/mysql_install_db'
  mysqld_binary: '/usr/sbin/mysqld'

general:
  log_level: 'DEBUG'
  timeout_start: 30
  timeout_stop: 30

Usage

import

from mysqld_integration_test import Mysqld

run

Starts up the mysql server

mysqld = Mysqld()
instance = mysqld.run()

stop

Stops the mysql server

mysqld.stop()

Example Code

#!/usr/bin/env python3

from mysqld_integration_test import Mysqld
import mysql.connector

mysqld = Mysqld(config='/some/dir/mysqld-integration-test.cfg')
instance = mysqld.run()

# Make query to database
cnx = mysql.connector.connect(user=instance.username, password=instance.password,
                      host=instance.host, port=instance.port)
cursor = cnx.cursor()
cursor.execute(f"SHOW databases;")

for db in cursor:
   print(db[0])

cursor.close()
cnx.close()

mysqld.stop()

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

mysqld_integration_test-0.0.28.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

mysqld_integration_test-0.0.28-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file mysqld_integration_test-0.0.28.tar.gz.

File metadata

File hashes

Hashes for mysqld_integration_test-0.0.28.tar.gz
Algorithm Hash digest
SHA256 1f262ed02fe9cf1c86eead98a218735d8eb5fb09563f8bd68e53175dea3435ac
MD5 7c970e7b322a1f2f7a73234fe0f32cd8
BLAKE2b-256 33addba895e13c84d9b38fe44c9b21d19758e3bf19d9b4826020816e35045947

See more details on using hashes here.

File details

Details for the file mysqld_integration_test-0.0.28-py3-none-any.whl.

File metadata

File hashes

Hashes for mysqld_integration_test-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 86db7905853d3cf9f4cd6a55dae91ba9c79fe970dc277c2ebbf728e87631c4d1
MD5 d941eaa489d4d9cc74ddbc6bc9fbeece
BLAKE2b-256 99c8190bd3dde020374d5ac2e3a7ee1244d7f8312c131ff844189f7f059a2806

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