modified: bot.py
This commit is contained in:
5
bot.py
5
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):
|
||||||
|
global db_connection, db_cursor # global-Deklaration muss vor dem Zugriff erfolgen
|
||||||
try:
|
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"
|
||||||
|
|
||||||
@@ -199,13 +200,15 @@ def update_user_data(user_id, field, value):
|
|||||||
if db_connection.is_connected():
|
if db_connection.is_connected():
|
||||||
db_cursor.close()
|
db_cursor.close()
|
||||||
db_connection.close()
|
db_connection.close()
|
||||||
|
|
||||||
# Verbindung neu aufbauen
|
# Verbindung neu aufbauen
|
||||||
global db_connection, db_cursor
|
|
||||||
db_connection = connect_to_database()
|
db_connection = connect_to_database()
|
||||||
db_cursor = db_connection.cursor()
|
db_cursor = db_connection.cursor()
|
||||||
|
|
||||||
# Wiederhole die Abfrage nach dem erneuten Verbinden
|
# Wiederhole die Abfrage nach dem erneuten Verbinden
|
||||||
update_user_data(user_id, field, value)
|
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