4d84586a9d
1. MySQL Connection 2. FastGPT database uploader
26 lines
606 B
Python
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.")
|