So I'm trying to commit unicode emoji to database (this one especially:)
But everytime something with emoji is executed on database this happens:
pymysql.err.OperationalError: (1300, "Invalid utf8mb4 character string: '\\xF0\\x9F\\x91\\x8C'")
I've read a little bit on this topic, and found out I should change charset to utf8mb4 to make unicode emojis work, so now my connection looks like this:
mydb = mysql.connect(host=os.getenv("db_host", "localhost"),
user=os.getenv("db_username", "Mashu"),
password=os.getenv("db_password"),
port=self._tunnel.local_bind_port,
db=os.getenv("database"),
charset='utf8mb4')
But it still refuses to work, I have no idea what to do now...
Whole code:
mydb = mysql.connect(host=os.getenv("db_host", "localhost"),
user=os.getenv("db_username", "Mashu"),
password=os.getenv("db_password"),
port=self._tunnel.local_bind_port,
db=os.getenv("database"),
charset='utf8mb4')
payload = Payload()
payload.id: int
payload.message_id: int
payload.channel_id: int
payload.emoji = ""
def foo(payload)
cursor = self.bot.mydb.cursor()
cursor.execute(
f"SELECT role FROM RR_Roles INNER JOIN RR_Panels ON RR_Roles.panel_id =
payload.id WHERE emoji = '{emoji}' AND guild = '{payload.channel_id}' AND
message = '{payload.message_id}'")
print(curosor.fetchone()[0]