Made database connections more efficient

pull/8/head
sgoudham 4 years ago
parent 9b4eeaec4c
commit fe98977695

@ -319,8 +319,7 @@ async def on_member_join(member):
# Define the insert statement that will insert the user's information # Define the insert statement that will insert the user's information
insert_query = """INSERT INTO members (guildID, discordUser, discordID) VALUES (?, ?, ?)""" insert_query = """INSERT INTO members (guildID, discordUser, discordID) VALUES (?, ?, ?)"""
vals = member.guild.id, name, member.id, vals = member.guild.id, name, member.id,
cursor = conn.cursor() with closing(conn.cursor()) as cursor:
# Execute the SQL Query # Execute the SQL Query
cursor.execute(insert_query, vals) cursor.execute(insert_query, vals)
conn.commit() conn.commit()
@ -377,8 +376,7 @@ async def on_member_remove(member):
# Delete the record of the member as they leave the server # Delete the record of the member as they leave the server
delete_query = """DELETE FROM members WHERE discordID = (?) AND guildID = (?)""" delete_query = """DELETE FROM members WHERE discordID = (?) AND guildID = (?)"""
vals = member.id, guild.id, vals = member.id, guild.id,
cursor = conn.cursor() with closing(conn.cursor()) as cursor:
# Execute the SQL Query # Execute the SQL Query
cursor.execute(delete_query, vals) cursor.execute(delete_query, vals)
conn.commit() conn.commit()

Loading…
Cancel
Save