Connect Python to MariaDB

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
SteveR
Level 3
Level 3
Posts: 112
Joined: Fri May 24, 2019 12:02 pm
Location: Morehead City, NC
Contact:

Connect Python to MariaDB

Post by SteveR »

Turned out that installing a Python to MariaDB connection on Linux Mint was not as simple as one would believe. The MariaDB website has a webpage devoted to installing a Python to MariaDB connector, so it appeared to be simple. A problem developed as the command "pip3 install mariadb" failed to work out-of-the-box. This command will eventually work after some installation gymnastics discussed below. Also note that other tutorials that I ran across when doing an internet search were outdated. This tutorial is based on using Mint 20.1. Eventually this tutorial will join the ranks of "outdated". Both MySQL and MariaDB have a lot of outdated tutorials. An unfortunate after effect resulting from new versions being developed.
  • If Python3-pip is not installed on your computer, it is available on the Mint repository under "software manager".
  • After downloading go to this webpage: MariaDB Connector/C. Go to the heading "Install via APT (Debian/Ubuntu)". Issue the command: "sudo apt install libmariadb3 libmariadb-dev". This is where the connector is loaded onto your computer for installation in the following steps.
  • In "/etc/mysql", create a directory: "mariadb-connector-python". Place the tarball: "connector-c-3.1.13/mariadb-connector-c-3.1.13-ubuntu-focal-amd64.tar.gz" in that directory. CD to that directory and unpack the tarball. Important: also see MariaDB Connector/Python. Read the tab: "Installing from Source" items 1-4. The list of items is helpful, but they had to be tweaked to work.
  • After unpacking, you can issue the command "pip3 install mariadb" to complete installation of the Python to MariaDB connector.
Good Luck!
Post Reply