when we install mysql,postgresql pacakage, we need install mysql-devel and libpq-devel , python need binary of the 2 package
In Red hat , we can run :
$ sudo dnf install gcc mysql-devel python3-devel ,
if we meet the similar issues when run " pip install psycopg2" ( this is python Postgresql pkg)
error : pg_config can not be found
we can run :
$ sudo dnf install
libpq-devel
when the above step is finished , and good ,
then run
$ pip install mysqlclient
then run the sample python , to test connection of Mysql:
############################
#! /usr/bin/env python
#print ("test")
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost","root","mySql_root_passwd")
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
if data:
print('Version available: ', data)
else:
print('Version not retrieved.')
# disconnect from server
db.close()
############################