Socket
Socket
Sign inDemoInstall

mysqld-integration-test

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mysqld-integration-test

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


Maintainers
1

Readme

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.

ArgumentDescriptionDefault
usernameUsername for databaseroot
passwordPassword for databaseroot
hostHost to bind127.0.0.1
portPort to bindrandom
mysql_install_db_binaryLocation of mysql_install_dbSearches paths
mysqld_binaryLocation of mysqldSearches paths
timeout_startTimeout to start MySQL30 seconds
timeout_stopTimeout to stop MySQL30 seconds
log_levelLog levelINFO
config_fileConfiguration filemysqld-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()

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc