pawan
pawan

Reputation: 21

MARIADB - Python Connection Issue

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

Upvotes: 1

Views: 16256

Answers (1)

Mauro Baraldi
Mauro Baraldi

Reputation: 6550

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.

Upvotes: 4

Related Questions