async def add_channel(self, uid, name, description, category):
if not self.ascii_checks([name, description, category]):
return 'Bad arguments.'
await self.db.execute(
"SELECT * FROM users_channels WHERE user_id=%s", (uid,))
if await self.db.fetchone() is not None:
await self.db.execute(
"SELECT channel_name FROM channels WHERE channel_id=%s", (self.db.fetchone(),))
return await self.db.fetchone()[0]
await self.db.execute(
"INSERT INTO users (user_id) "
"VALUES (%s)", (uid, ))
await self.db.execute(
"INSERT INTO channels (channel_id, channel_name, description, category) "
"VALUES (%s, %s, %s)", (1, name, description, category))
await self.db.execute("SELECT LAST_INSERT_ID();")
channel_id = await self.db.fetchone()
await self.db.execute(
"INSERT INTO users_channels (user_id, channel_id) "
"VALUES (%s, %s)", (uid, channel_id))
await self.conn.commit()
return 'Successful'
I've got this working. The problem is I'm using LAST_INSERT_ID(), would this work async? in a discord bot, if two people execute this command at once, would the ids glitch out?


