{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreic66cuvc27u37qc5pcqq2h7u6dfwwmrueheemxcynsgu4a4claxya",
    "uri": "at://did:plc:nag2oldw2cdjruz3dtaxj52d/app.bsky.feed.post/3mjshkfmbswv2"
  },
  "path": "/en/blog/2025/conector-mysql-para-python-en-manjaro/",
  "publishedAt": "2026-04-18T05:00:00.000Z",
  "site": "https://www.cosmoscalibur.com",
  "tags": [
    "Python mariadb connector",
    "PyMySQL",
    "install_as_mysqldb"
  ],
  "textContent": "Now that I use Manjaro instead of Ubuntu, one of the problems I encountered when adapting the development environment I use for work, is that the MySQL connector for Python _MySQLdb_ depends on `libmysqlclient-dev`, which is not available in Manjaro. Here is how I solved the problem.\n\n## MySQL Connector\n\nThe database connector provides an interface to interact with databases from an application. Database vendors offer their own connectors for different programming languages, native drivers that allow the community to interact with the databases by creating new extensions or even the definition of the standard so that there are implementations in different languages and that have no dependencies with the operating system.\n\nIn the case of the MySQL connector for Python, the official connector depends on `libmysqlclient-dev` (with the `mysqlclient` python package), which is not available in Manjaro.\n\n## Alternatives for Python connection with MySQL on Manjaro\n\nWe can have two alternatives to connect to MySQL from Python on Manjaro, considering a native connection, but also a connection without dependencies with the operating system.\n\n### MariaDB Connector\n\nMariaDB is an open source relational database based on the MySQL source code. It is compatible with most MySQL features and offers improvements in security, performance, and scalability. This compatibility offers an alternative to the native MySQL connection with which we can install `mysqlclient` with our Python package manager as usual. To install native dependencies, in Manjaro and Arch derivatives, we proceed as follows:\n\n\n    pamac install mariadb-libs\n\nNow we can install the `mysqlclient` Python package with our Python package manager in the usual way (package in the environment or in the project):\n\n\n    uv pip install mysqlclient # Installation in the environment uv add mysqlclient # Installation in the project\n\n### Pure Python MySQL Connector\n\nThere is also a pure Python MySQL connector that also meets the standard for database connections defined by PEP 249, just like the native connector. This option is _PyMySQL_ , and it is an excellent alternative if you cannot install the native dependencies of MySQL or MariaDB, or simply prefer not to install them.\n\nTo install PyMySQL, we simply execute the following command:\n\n\n    uv pip install PyMySQL # Installation in the environment uv add PyMySQL # Installation in the project\n\nNow you can use `pymysql` directly in your projects, or use it as a substitute for `MySQLdb` when the native dependency is not available, which is done as follows:\n\n\n    try: import MySQLdb except ImportError: import pymysql # Replaces `MySQLdb` with `pymysql` pymysql.install_as_MySQLdb()\n\n### Other alternatives\n\nTo configure the development environment you could have other options, and I will briefly comment on two more. Through AUR, you can install the native MySQL dependencies, but I consider that having options that do not pollute the system, we can omit it. The other alternative is that a suitable development environment would be to adapt a local container based on Ubuntu, in order to properly replicate the production environment. Without a doubt, I will tell you a bit more about Docker later, but for now I prefer the convenience of having the environment directly in Manjaro without the container (the integration of the IDE I use, Zed, does not seem that good yet).\n\n## References\n\n  * Python mariadb connector. Manjaro Linux Forum.\n\n  * PyMySQL. Documentation.\n\n  * install_as_mysqldb. GitHub PyMySQL.\n\n\n",
  "title": "MySQL Connector for Python on Manjaro",
  "updatedAt": "2026-04-18T05:00:00.000Z"
}