fastdoi/mysql_connector.py
mxr612 4d84586a9d 0. Configs
1. MySQL Connection
2. FastGPT database uploader
2024-08-19 22:13:16 +08:00

26 lines
606 B
Python

# ConfigMysql
from config import __CONFIG__
import mysql.connector
mysql_config = {
'user': __CONFIG__['mysql_user'],
'password': __CONFIG__['mysql_password'],
'host': __CONFIG__['mysql_host'], # Typically 'localhost' if the database is on the same machine
'database': 'fastdoi',
'raise_on_warnings': True
}
# Establish a connection to the MySQL database
cnx = mysql.connector.connect(**mysql_config)
cursor = cnx.cursor()
def end_mysql():
try:
# Close the cursor and connection
cursor.close()
cnx.close()
except:
print("No Mysql Opened.")