You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
601 B

import mysql.connector
from mysql.connector import errorcode
import db.read_config as config
def get_new_mysql_connection():
db_config = config.read_db_config('../db_config.ini', 'mysql')
connection = None
try:
connection = mysql.connector.connect(**db_config)
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print('Invalid Database User and Password')
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print('Database doesn\'t exist ')
else:
print(err)
return connection