I’m trying to get my user id and write it into mysql db.
The problem occurs at the moment when I try to write this data (31-34). It writes random id into db (2147483647), but i need to write my user id (1003694956919148625). Any ideas?
class MyModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Name"))
self.add_item(discord.ui.InputText(label="Gender"))
self.add_item(discord.ui.InputText(label="City"))
self.add_item(discord.ui.InputText(label="Description", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
id = interaction.user.id
print(id)
cursor = connection.cursor()
cursor.execute(
"INSERT INTO users (id, name, gender, city, description) VALUES (%s, %s, %s, %s, %s)",
(id, self.children[0].value, self.children[1].value, self.children[2].value, self.children[3].value)
)
connection.commit()
In console print id is correct
But in db – it isn’t
I tried to print id in console – it works
I tried to save id in MySQL – in not works
>Solution :
Which type are you using for the id in the db?
I recommend you to store it in an varchar or text column. Otherside, there can be problems with the type or overflow of the value