Virtual Package for MySQL-python (Deprecated)
The `mysql` package on PyPI is a virtual package, currently at version 0.0.3. It does not provide actual MySQL connectivity. Its primary purpose, especially for version 0.0.3, is to raise a `RuntimeError` upon installation or import, directing users to install proper MySQL client libraries like `mysqlclient` or `PyMySQL` directly. It has a very slow release cadence, with the last update in May 2021, and serves as a placeholder to guide users away from outdated dependencies.
Warnings
- breaking The `mysql` package (version 0.0.3 and later) does not provide any functionality. Attempting to import or use it will raise a `RuntimeError`, explicitly instructing users to install `mysqlclient` or `PyMySQL` instead.
- gotcha Users often install `mysql` expecting it to be a functional MySQL connector. However, it is a virtual package designed to redirect, not implement, database connectivity. Older versions (pre-0.0.3) might have attempted to install `MySQL-python` (Python 2 only) or `mysqlclient` as a dependency, leading to inconsistent behavior.
- deprecated The practice of using a 'virtual package' like `mysql` to indirectly manage dependencies is largely deprecated. Direct dependency management is preferred for clarity and stability.
- gotcha The `MySQL-python` library, which older versions of this virtual package historically pointed to, is a Python 2-only library and is largely unmaintained. It will not work with Python 3 environments.
Install
-
pip install mysql
Quickstart
# The 'mysql' package (0.0.3) does not provide a functional API.
# It will raise a RuntimeError upon import or use, directing you to install
# 'mysqlclient' or 'PyMySQL' instead.
# For example, to use mysqlclient:
# pip install mysqlclient
# import MySQLdb
# conn = MySQLdb.connect(host='localhost', user=os.environ.get('MYSQL_USER', 'user'), password=os.environ.get('MYSQL_PASSWORD', 'password'), database=os.environ.get('MYSQL_DATABASE', 'test_db'))
# cursor = conn.cursor()
# cursor.execute('SELECT VERSION()')
# print(cursor.fetchone())
# conn.close()
# Or to use PyMySQL:
# pip install PyMySQL
# import pymysql
# connection = pymysql.connect(host='localhost', user=os.environ.get('MYSQL_USER', 'user'), password=os.environ.get('MYSQL_PASSWORD', 'password'), database=os.environ.get('MYSQL_DATABASE', 'test_db'))
# with connection.cursor() as cursor:
# cursor.execute('SELECT VERSION()')
# print(cursor.fetchone())
# connection.close()