--- id: pytest-mysql version: "4.0.0" license: GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this… (full text in the JSON record) license_treatment: copyleft maintenance: active --- # pytest-mysql — MySQL process and client fixtures for pytest License: copyleft · Maintenance: active · Downloads: 276.1K/mo ## What it is and what it does pytest-mysql is a pytest plugin that automates MySQL and MariaDB database setup for integration tests. It provides three main fixtures: mysql (a function-scoped client that drops the test database after each test), mysql_proc (a session-scoped process that starts a local MySQL instance), and mysql_noproc (a session-scoped fixture for connecting to an already-running database). The plugin depends on pytest, port-for, mirakuru, pymysql, and packaging to manage process lifecycle, port allocation, and database connections. You use it by installing the plugin and then importing fixtures into your test suite. Configuration is flexible—you can set options via fixture factory arguments, command-line flags, or pytest.ini entries. The plugin handles port discovery, database creation, user authentication, and cleanup automatically, making it straightforward to write repeatable database tests without manual setup or teardown boilerplate. Use it for: - Write integration tests that verify application code against a real MySQL database without manual server management. - Run isolated test suites in CI/CD pipelines where each test gets a clean database and the server starts and stops automatically. - Connect tests to a MySQL instance running in Docker or on a remote host using the noproc fixture. - Populate test databases with SQLAlchemy ORM or raw SQL and verify application behavior against schema changes. - Configure different MySQL instances for different test fixtures with custom ports, users, and parameters. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that provides MySQL and MariaDB fixtures for testing—manages both local database processes and connections to running instances, with automatic cleanup between tests. Yes. This is a stable, actively maintained plugin with low install friction and no known vulnerabilities. It solves a real problem—automating MySQL test infrastructure—and is widely used. The LGPLv3+ license is permissive for test code. Install it if your test suite needs a managed MySQL database. ## Install pip install pytest-mysql uv add pytest-mysql poetry add pytest-mysql ## Installing pytest-mysql Before you install: Low friction install with five runtime dependencies (pytest, port-for, mirakuru, pymysql, packaging). Actively maintained with recent releases. License in practice: Licensed under LGPLv3+, a copyleft license. Your test code using this plugin must comply with LGPL terms; derivative works of the plugin itself require source disclosure, but linking to it from proprietary tests is permitted under LGPL's library exception. Quickstart: pip install pytest-mysql In conftest.py or test file: from pytest_mysql import factories mysql_proc = factories.mysql_proc() mysql = factories.mysql('mysql_proc') def test_example(mysql): cur = mysql.cursor() cur.execute('SELECT 1') mysql.commit() Requires MySQL 8.0+ or MariaDB 10.11+ installed on the test machine; mysqld and mysqladmin binaries must be in PATH or configured via fixture arguments. Verify before relying: - Whether the plugin supports Python versions beyond 3.14 or if 3.14 is the current ceiling. - Performance characteristics when running many concurrent test fixtures or large test suites. - Compatibility with MySQL 8.1+ or MariaDB 11.0+ versions released after the tested range. ## Package facts - License: GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this… (full text in the JSON record) (copyleft) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 276.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest mysql fixture, mysql testing plugin, mariadb pytest, database test fixtures, mysql process management, pytest database setup, mysql test isolation, pytest-plugin, database-testing, mysql-mariadb [View on SkillFed](https://skillfed.io/packages/pytest-mysql) · [View on PyPI](https://pypi.org/project/pytest-mysql/)