Making connection more efficient with "with" statement

Adding Commentary
pull/4/head
sgoudham 5 years ago
parent 84f376465d
commit 03e8128610

@ -162,13 +162,10 @@ def SendMsgToModMail(self, msg, author):
return embed
# Method to allow
# Method to allow modmail to be logged into the database
def logModMail(ctx, anon, msg):
# Set up the connection to the database
conn = db.connection()
# With the connection
with conn:
# With the database connection
with db.connection() as conn:
# Make sure that mariaDB errors are handled properly
try:
if anon:

@ -37,11 +37,8 @@ async def on_message(message):
pass
else:
# Set up the connection to the database
conn = db.connection()
# With the connection
with conn:
# Using connection to the database
with db.connection() as conn:
# Make sure that mariaDB errors are handled properly
try:

Loading…
Cancel
Save