{"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":"python","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,"search_vec":"'0.0.3':20,34 '2021':70 'actual':25 'away':79 'cadenc':63 'client':50 'connect':27,90 'current':17 'databas':83 'depend':82 'deprec':7,88 'direct':44,56 'especi':31 'guid':77 'import':43 'instal':41,47 'last':66 'legaci':89 'librari':51 'like':52 'may':69 'mysql':5,9,26,49,84 'mysql-python':4 'mysqlclient':53 'outdat':81 'packag':2,10,16,87 'placehold':75 'primari':29 'proper':48 'provid':24 'purpos':30 'pymysql':55 'pypi':12 'python':6 'rais':37 'releas':62 'runtimeerror':39 'serv':72 'slow':61 'updat':67 'upon':40 'user':45,78 'version':19,33 'virtual':1,15,86 'virtual-packag':85","created_at":"2026-04-15T18:40:40.448351+00:00","updated_at":"2026-04-16T17:18:07.263241+00:00","problems":[{"fix":"Install a proper MySQL client library such as 'mysql-connector-python', 'mysqlclient', or 'PyMySQL' (e.g., `pip install mysql-connector-python`).","cause":"Developers often install the placeholder 'mysql' package from PyPI, which does not provide an actual 'mysql' module, and then attempt to import 'mysql' or 'mysql.connector' assuming it was installed.","error":"ModuleNotFoundError: No module named 'mysql'"},{"fix":"After installing a proper MySQL client (e.g., `pip install mysql-connector-python`), import the specific connector module (e.g., `import mysql.connector`).","cause":"Developers mistakenly try to import 'mysql' directly, expecting it to be the main module for MySQL connectivity, rather than specific, separately installed client libraries like 'mysql.connector' or 'PyMySQL'.","error":"import mysql"},{"fix":"Install the MySQL development headers specific to your operating system. For Debian/Ubuntu, use `sudo apt-get install libmysqlclient-dev`; for macOS, use `brew install mysql-client`; for Windows, install the MySQL Connector/C++ Development Headers.","cause":"This error occurs during the installation of 'mysqlclient', a C extension, because the MySQL client development headers and libraries, which are required for compilation, are missing on the system.","error":"fatal error: my_config.h: No such file or directory"},{"fix":"Ensure all required build tools and MySQL client development headers are installed on your system (e.g., `sudo apt-get install build-essential libmysqlclient-dev` on Debian/Ubuntu, install Xcode command line tools and MySQL client on macOS, or Visual C++ build tools and MySQL Connector/C++ on Windows).","cause":"This general build error when installing 'mysqlclient' typically indicates that necessary system-level dependencies, such as MySQL development headers, 'pkg-config', or a C compiler, are missing and required to compile the C extension.","error":"ERROR: Failed building wheel for mysqlclient"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/valhallasw/virtual-mysql-pypi-package","docs":null,"changelog":null,"pypi":"https://pypi.org/project/mysql/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-15","next_check":"2026-07-14","install_tag":null}}