Skip to content

Commit 5c52c02

Browse files
committed
Fixed database message logger charset
Signed-off-by: ColaIan <colaian.yt@gmail.com>
1 parent da9c79f commit 5c52c02

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Teapot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
db.execute("CREATE TABLE IF NOT EXISTS `users` (`user_id` BIGINT, `user_name` TINYTEXT, `user_discriminator` INT)")
3939
db.execute("CREATE TABLE IF NOT EXISTS `bot_logs` (`timestamp` TEXT, `type` TINYTEXT, `class` TINYTEXT, `message` "
4040
"MEDIUMTEXT)")
41+
teapot.managers.database.create_table(
42+
"CREATE TABLE IF NOT EXISTS `guild_logs` (`timestamp` TEXT, `guild_id` BIGINT, `channel_id` BIGINT, "
43+
"`message_id` BIGINT, `user_id` BIGINT, `action_type` TINYTEXT, `message` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci)")
44+
4145
print(
4246
f"Connected to database ({teapot.config.db_host()}:{teapot.config.db_port()}) in {round(time.perf_counter() - time_start, 2)}s")
4347

teapot/managers/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ def __init__():
2727
database = mysql.connector.connect(
2828
host=teapot.config.db_host(),
2929
port=teapot.config.db_port(),
30-
database=teapot.config.db_schema(),
30+
db=teapot.config.db_schema(),
3131
user=teapot.config.db_user(),
32-
passwd=teapot.config.db_password()
32+
passwd=teapot.config.db_password(),
33+
charset='utf8mb4',
34+
use_unicode=True
3335
)
3436
return (database)
3537
except Exception as error:
@@ -83,5 +85,3 @@ def create_guild_table(guild):
8385
db.execute("SELECT * FROM `guilds` WHERE guild_id = '" + str(guild.id) + "'")
8486
if db.rowcount == 0:
8587
insert("INSERT INTO `guilds`(guild_id, guild_name) VALUES(%s, %s)", (guild.id, guild.name))
86-
create_table("CREATE TABLE IF NOT EXISTS `guild_logs` (`timestamp` TEXT, `guild_id` BIGINT, `channel_id` BIGINT, "
87-
"`message_id` BIGINT, `user_id` BIGINT, `action_type` TINYTEXT, `message` MEDIUMTEXT)")

0 commit comments

Comments
 (0)