diff --git a/main.py b/main.py index f7f3e37b..b85c51bf 100644 --- a/main.py +++ b/main.py @@ -157,17 +157,17 @@ async def _help(ctx, *, command: Optional[str] = None): async def reload_db(ctx): pool = await db.connection2(db.loop) - with db.connection() as conn: - with closing(conn.cursor()) as cursor: + async with pool.acquire() as conn: + async with conn.cursor() as cur: # Define the insert statement that will insert the user's information insert = "INSERT IGNORE INTO members (guildID, discordID) VALUES " + ", ".join( map(lambda m: f"({ctx.guild.id}, {m.id})", ctx.guild.members)) try: # Execute the query - cursor.execute(insert) + await cur.execute(insert) except Exception as e: print(e) - print(cursor.rowcount, f"Record(s) inserted successfully into Members from {ctx.guild.name}") + print(cur.rowcount, f"Record(s) inserted successfully into Members from {ctx.guild.name}") @client.command(name="prefix", aliases=["Prefix"]) @@ -214,7 +214,7 @@ async def on_guild_join(guild): print(cursor.rowcount, f"Record inserted successfully into Guilds from {guild.name}") # Define the insert statement that will insert the user's information - insert = "INSERT INTO members (guildID, discordID) VALUES" + ", ".join( + insert = "INSERT IGNORE INTO members (guildID, discordID) VALUES" + ", ".join( map(lambda m: f"({guild.id}, {m.id})", guild.members)) with closing(conn.cursor()) as cursor: # Execute the query