Registry / testing / testcontainers-mysql

testcontainers-mysql

JSON →
library0.0.1rc1pypypiunverified

MySQL component of testcontainers-python, providing lightweight MySQL database containers for integration testing. Compatible with testcontainers core. Current version: 0.0.1rc1 (pre-release). Release cadence: follows testcontainers-python releases (monthly).

pip install testcontainers-mysql
INSTALL
IMPORT
SIG · TESTCONTAINERS-MYS
T
testcontainers-mysql
testingpythonv0.0.1rc1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MySQLContainer
from testcontainers.mysql import MySQLContainer
from testcontainers.mysql import MySQLContainer

Start a MySQL 8.0 container, get connection parameters, and run a query.

from testcontainers.mysql import MySQLContainer with MySQLContainer('mysql:8.0') as mysql: connection_url = mysql.get_connection_url() print(f"Connection URL: {connection_url}") # Use the connection URL with a MySQL driver import pymysql conn = pymysql.connect(**mysql.get_connection_params()) cursor = conn.cursor() cursor.execute("SELECT version();") print(cursor.fetchone()) conn.close()
Debug
Known issues
breakingMySQLContainer requires a Docker image tag (e.g., 'mysql:8.0') as of v0.0.1rc1. Older versions may have used a default tag, which no longer works.
fix
Always specify an image tag: MySQLContainer('mysql:8.0').
affects: >=0.0.1rc1
gotchaget_connection_url() returns a JDBC-style URL (jdbc:mysql://...). Use get_connection_params() to get a dict suitable for Python drivers (pymysql, mysql-connector-python).
fix
Use mysql.get_connection_params() for Python driver connections.
affects: all
gotchaContainer may fail silently if Docker is not running or if ports are occupied. Always check container logs or use wait_for() strategies.
fix
Ensure Docker is running and free ports are available. Use with statement for automatic cleanup.
affects: all
Upgrade
Version history
0.0.1rc1latest on PyPI · released Jan 6, 2023
Audit
Dependencies
testcontainersrequiredCore library required; provides base container classes and Docker management.
mysql-connector-pythonoptionalCommonly used MySQL driver for connecting to the container.
pymysqloptionalAlternative MySQL driver.
Agent activity
17 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
testcontainers-mysql — pip install testcontainers-mysql · libregistry