{"id":6734,"library":"mysql","title":"Virtual Package for MySQL-python (Deprecated)","description":"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.","status":"deprecated","version":"0.0.3","language":"en","source_language":"en","source_url":"https://github.com/valhallasw/virtual-mysql-pypi-package","tags":["database","mysql","virtual-package","deprecated","legacy","connectivity"],"install":[{"cmd":"pip install mysql","lang":"bash","label":"Installation for the virtual package"}],"dependencies":[],"imports":[],"quickstart":{"code":"# The 'mysql' package (0.0.3) does not provide a functional API.\n# It will raise a RuntimeError upon import or use, directing you to install\n# 'mysqlclient' or 'PyMySQL' instead.\n# For example, to use mysqlclient:\n# pip install mysqlclient\n# import MySQLdb\n# 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'))\n# cursor = conn.cursor()\n# cursor.execute('SELECT VERSION()')\n# print(cursor.fetchone())\n# conn.close()\n\n# Or to use PyMySQL:\n# pip install PyMySQL\n# import pymysql\n# 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'))\n# with connection.cursor() as cursor:\n#     cursor.execute('SELECT VERSION()')\n#     print(cursor.fetchone())\n# connection.close()","lang":"python","description":"The `mysql` package itself does not offer a quickstart because its intended behavior is to prevent usage and guide developers to a suitable, actively maintained MySQL connector. The code provided illustrates the typical usage patterns for recommended alternatives like `mysqlclient` (which uses `MySQLdb` for imports) or `PyMySQL`."},"warnings":[{"fix":"Do not depend on `mysql`. Instead, install and use `mysqlclient` (for C-extension based driver, `pip install mysqlclient`) or `PyMySQL` (for pure Python driver, `pip install PyMySQL`).","message":"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.","severity":"breaking","affected_versions":"0.0.3+"},{"fix":"Always explicitly choose and install a maintained MySQL connector like `mysqlclient` or `PyMySQL`. Check their respective PyPI pages and documentation for current installation and usage instructions.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update `requirements.txt` or `pyproject.toml` to directly list `mysqlclient` or `PyMySQL` as dependencies.","message":"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.","severity":"deprecated","affected_versions":"All versions"},{"fix":"For Python 3, use `mysqlclient` or `PyMySQL`. If you strictly require `MySQL-python` (e.g., for a legacy Python 2 application), ensure your environment is Python 2 compatible and understand that `MySQL-python` is not actively developed.","message":"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.","severity":"gotcha","affected_versions":"<0.0.3 (indirectly), Python 2 users"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}