modified: bot.py
This commit is contained in:
13
bot.py
13
bot.py
@@ -181,6 +181,7 @@ def insert_user_data(user_id, permission, points, ban, askmultus, filter_value,
|
|||||||
|
|
||||||
|
|
||||||
def update_user_data(user_id, field, value):
|
def update_user_data(user_id, field, value):
|
||||||
|
try:
|
||||||
update_query = f"UPDATE user_data SET {field} = %s WHERE user_id = %s"
|
update_query = f"UPDATE user_data SET {field} = %s WHERE user_id = %s"
|
||||||
|
|
||||||
# Überprüfen, ob das Feld 'chat_history' aktualisiert wird
|
# Überprüfen, ob das Feld 'chat_history' aktualisiert wird
|
||||||
@@ -193,6 +194,18 @@ def update_user_data(user_id, field, value):
|
|||||||
|
|
||||||
db_connection.commit()
|
db_connection.commit()
|
||||||
|
|
||||||
|
except mysql.connector.Error as err:
|
||||||
|
logger.error(f"Database error: {err}")
|
||||||
|
if db_connection.is_connected():
|
||||||
|
db_cursor.close()
|
||||||
|
db_connection.close()
|
||||||
|
# Verbindung neu aufbauen
|
||||||
|
global db_connection, db_cursor
|
||||||
|
db_connection = connect_to_database()
|
||||||
|
db_cursor = db_connection.cursor()
|
||||||
|
# Wiederhole die Abfrage nach dem erneuten Verbinden
|
||||||
|
update_user_data(user_id, field, value)
|
||||||
|
|
||||||
def connect_to_database():
|
def connect_to_database():
|
||||||
return mysql.connector.connect(
|
return mysql.connector.connect(
|
||||||
host=DB_HOST,
|
host=DB_HOST,
|
||||||
|
|||||||
Reference in New Issue
Block a user