modified: bot.py

This commit is contained in:
SimolZimol
2026-01-09 21:49:39 +01:00
parent 2ee44c21dd
commit 140c6a51c7

12
bot.py
View File

@@ -41,6 +41,8 @@ def get_db_connection():
def init_db():
conn = get_db_connection()
cursor = conn.cursor()
# Create tables with utf8mb4 charset
cursor.execute('''
CREATE TABLE IF NOT EXISTS tickets (
ticket_id VARCHAR(32) PRIMARY KEY,
@@ -62,6 +64,16 @@ def init_db():
archive_channel_id BIGINT
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
''')
# Convert existing tables to utf8mb4 if needed
try:
cursor.execute('ALTER TABLE tickets CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci')
cursor.execute('ALTER TABLE server_settings CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci')
print("Database tables converted to utf8mb4")
except Exception as e:
# Tables might already be utf8mb4 or might not exist yet
print(f"Table conversion info: {e}")
conn.commit()
cursor.close()
conn.close()