1

Issue - On CENTOS 7, I have installed MARIADB 10.x which is working perfectly fine, I tested with DBeaver.

to connect MARIA DB 10.x from PYTHON 2.7, I have installed "MySQL-python 1.2.5" as recommended "https://mariadb.com/blog/how-connect-python-programs-mariadb".

But getting below error while testing, Please help with this.

import mysql.connector as mariadb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector

1 Answer 1

4

UPDATE

The lib MySQLdb1 is not maintained anymore. The MySQL company maintain a connector project.

Use MySQL Connector for Python as MariaDB database connection.

import MySQLdb as mariadb
conn = mariadb.connect(user='username', passwd='1a2b3c', db='defaultdb')
cursor = conn.cursor()

The lib mentioned on MariaDB docs is the one officialy builded by MySQL. Using this lib you will be able to follow the tutorial.

As @nizam-mohamed mentioned in comments, there is a a fork from MySQLdb1, mysqlclient.

Sign up to request clarification or add additional context in comments.

2 Comments

this worked fine, but seems this is old libraries. And, any reason why mysql.connector is not working
The connector described on MariaDB docs is the one offered by MySQL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.