{"id":8341,"library":"mysql-connector-python-rf","title":"MySQL Connector/Python (RF variant)","description":"An old, unmaintained variant of the pure Python MySQL driver for Python, implementing the DB API v2.0 specification (PEP-249). This package was released to PyPI to address distribution issues with the official 'mysql-connector-python' around 2015-2017. It is currently at version 2.2.2 and has not been updated since February 2017.","status":"abandoned","version":"2.2.2","language":"en","source_language":"en","source_url":"https://pypi.org/project/mysql-connector-python-rf/","tags":["mysql","database","sql","db-api","deprecated"],"install":[{"cmd":"pip install mysql-connector-python-rf","lang":"bash","label":"Install"}],"dependencies":[],"imports":[{"note":"This library was a repackaging of the official `mysql-connector-python` at the time, and therefore used the same `mysql.connector` import path.","symbol":"mysql.connector","correct":"import mysql.connector"},{"note":"The core connection class, following DB-API 2.0 standards.","symbol":"MySQLConnection","correct":"from mysql.connector import MySQLConnection"}],"quickstart":{"code":"import mysql.connector\nimport os\n\nhost = os.environ.get('MYSQL_HOST', 'localhost')\nuser = os.environ.get('MYSQL_USER', 'your_user')\npassword = os.environ.get('MYSQL_PASSWORD', 'your_password')\ndatabase = os.environ.get('MYSQL_DATABASE', 'test_db')\n\ntry:\n    # Establish a connection\n    cnx = mysql.connector.connect(\n        host=host,\n        user=user,\n        password=password,\n        database=database\n    )\n\n    if cnx.is_connected():\n        print(\"Successfully connected to MySQL database.\")\n\n        cursor = cnx.cursor()\n        # Create a table (if it doesn't exist)\n        cursor.execute(\"CREATE TABLE IF NOT EXISTS users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255))\")\n        cnx.commit()\n        print(\"Table 'users' ensured to exist.\")\n\n        # Insert data\n        add_user = (\"INSERT INTO users (name, email) VALUES (%s, %s)\")\n        data_user = (\"John Doe\", \"john.doe@example.com\")\n        cursor.execute(add_user, data_user)\n        cnx.commit()\n        print(\"Data inserted.\")\n\n        # Query data\n        cursor.execute(\"SELECT id, name, email FROM users\")\n        for (id, name, email) in cursor:\n            print(f\"ID: {id}, Name: {name}, Email: {email}\")\n\n    else:\n        print(\"Failed to connect to MySQL database.\")\n\nexcept mysql.connector.Error as err:\n    print(f\"Error: {err}\")\n\nfinally:\n    if 'cnx' in locals() and cnx.is_connected():\n        cursor.close()\n        cnx.close()\n        print(\"MySQL connection closed.\")","lang":"python","description":"This quickstart demonstrates how to connect to a MySQL database, create a table, insert data, and query data using the `mysql.connector` module. It follows the standard Python DB-API 2.0 pattern and includes basic error handling and proper resource cleanup."},"warnings":[{"fix":"**DO NOT USE THIS PACKAGE.** Migrate immediately to the official and actively maintained `mysql-connector-python` (install via `pip install mysql-connector-python`).","message":"This library (`mysql-connector-python-rf`) is *abandoned and unmaintained*. Its last release was in February 2017, making it incompatible with modern Python versions and potentially containing unpatched security vulnerabilities.","severity":"breaking","affected_versions":"All versions (2.2.2 and earlier)"},{"fix":"Use the official Oracle-maintained `mysql-connector-python` library. It offers full Python 3 compatibility and active development.","message":"The package `mysql-connector-python-rf` was a temporary repackaging to resolve PyPI distribution issues of the official connector. It is severely outdated and not compatible with Python versions beyond 3.3.","severity":"deprecated","affected_versions":"All versions (2.2.2 and earlier)"},{"fix":"Always call `connection.commit()` after any operation that modifies the database (e.g., `cnx.commit()` in the quickstart). Alternatively, use a `with` statement for connections if the driver supports auto-commit or transaction management via context.","message":"Forgetting to call `connection.commit()` after executing DML (INSERT, UPDATE, DELETE) statements will result in changes not being saved to the database. This is a common DB-API 2.0 footgun.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the correct package is installed: `pip install mysql-connector-python-rf` (though highly discouraged) or `pip install mysql-connector-python` (recommended).","cause":"The `mysql-connector-python-rf` package or its official counterpart `mysql-connector-python` is not installed in the active Python environment.","error":"ModuleNotFoundError: No module named 'mysql.connector'"},{"fix":"Verify the username, password, and host parameters in `mysql.connector.connect()`. Ensure the MySQL user has the necessary permissions on the target database.","cause":"Incorrect database user credentials (username or password) or insufficient privileges for the specified user.","error":"mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'your_user'@'localhost' (using password: YES)"},{"fix":"Check if the MySQL server is running and accessible. Verify the `host` and `port` parameters in the connection string. Ensure no firewall is blocking the connection.","cause":"The MySQL server is not running, is not accessible from the client machine, or the connection parameters (host, port) are incorrect.","error":"mysql.connector.errors.InterfaceError: 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)"},{"fix":"Carefully review the SQL string passed to `cursor.execute()` for typos, incorrect keywords, or missing clauses. Use parameterized queries (`%s` placeholders) to prevent SQL injection and properly handle special characters.","cause":"The SQL query being executed contains a syntax error or is malformed.","error":"mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual..."}]}