Using PyMySQL with MariaDB

2024/10/13 18:23:17

I have read this article about switching from MySQL to MariaDB on Ubuntu. The article claims that it would be not problem to switch between the two.

Currently, I am using PyMySQL to connect to my MySQL database and insert, update and delete values from it.

My question is: can I just upgrade to MariaDB and keep on using my Python code? Will PyMySQL also connect correctly to MariaDB?

Answer

As documented under MariaDB versus MySQL - Compatibility:

MariaDB is a binary drop in replacement for MySQL

For all practical purposes, MariaDB is a binary drop in replacement of the same MySQL version (for example MySQL 5.1 -> MariaDB 5.1, MariaDB 5.2 & MariaDB 5.3 are compatible. MySQL 5.5 is compatible with MariaDB 5.5 and also in practice with MariaDB 10.0). What this means is that:

  • Data and table definition files (.frm) files are binary compatible.
    • See note below for an incompatibility with views!
  • All client APIs, protocols and structs are identical.
  • All filenames, binaries, paths, ports, sockets, and etc... should be the same.
  • All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB.
    • There are some installation issues with PHP5 that you should be aware of (a bug in how the old PHP5 client checks library compatibility).
  • The mysql-client package also works with MariaDB server.
  • The shared client library is binary compatible with MySQL's client library.

This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go. (No need to convert any datafiles if you use same main version, like 5.1). You must however still run mysql_upgrade to finish the upgrade. This is needed to ensure that your mysql privilege and event tables are updated with the new fields MariaDB uses.

The article goes on to list a few minor incompatibilities, which you should check your application(s) do not rely upon.

https://en.xdnf.cn/q/118048.html

Related Q&A

Overloading str in Python

I have code that looks like the following:class C(str):def __init__(self, a, b):print(init was called!)super().__init__(b)self.a = ac = C(12, c)When I try to run it, it gives me the following error:Tra…

Why cant I install Pillow on my mac? It gives some errors

here is the error from installing Pillow. Im using OS X Mavericks. I tried installing Pillow through pip install.._imaging.c:391:28: warning: implicit conversion loses integer precision: long to int [-…

what on earth the unicode number is?

in python:>>> "\xc4\xe3".decode("gbk").encode("utf-8") \xe4\xbd\xa0 >>> "\xc4\xe3".decode("gbk") u\u4f60we can get two conclusions:1.…

explicitly setting style sheet in python pyqt4?

In pyqt standard way for setting style sheet is like this:MainWindow.setStyleSheet(_fromUtf8("/*\n" "gridline-color: rgb(85, 170, 255);\n" "QToolTip\n" "{\n" &qu…

missing required Charfield in django is saved as empty string and do not raise an error

If I try to save incomplete model instance in Django 1.10, I would expect Django to raise an error. It does not seem to be the case.models.py:from django.db import modelsclass Essai(models.Model):ch1 =…

Beautiful soup missing some html table tags

Im trying to extract data from a website using beautiful soup to parse the html. Im currently trying to get the table data from the following webpage :link to webpageI want to get the data from the tab…

403 error Not Authorized to access this resource/api Google Admin SDK in web app even being admin

Im struggling to find the problem since two days without any idea why I get this error now even though the app was fully functional one month before.Among the tasks done by the web app, it makes an Adm…

Kivy - My ScrollView doesnt scroll

Im having problems in my Python application with Kivy library. In particular Im trying to create a scrollable list of elements in a TabbedPanelItem, but I dont know why my list doesnt scroll.Here is my…

How to get an associated model via a custom admin action in Django?

Part 2 of this question asked and answered separately.I have a Report and a ReportTemplate. +----+----------+---------------+-------------+ | id | title | data | template_id | +----+-------…

How can I use descriptors for non-static methods?

I am aware that I can use descriptors to change static property as if it were a normal property. However, when I try using descriptors for a normal class property, I end up changing the object it refer…