added connection closing statements to most database.py functions
This commit is contained in:
parent
8b9d5c2723
commit
0a1f1a9e73
17
database.py
17
database.py
|
@ -186,9 +186,13 @@ def get_user_player_conn(conn, user):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print(conn)
|
conn.close()
|
||||||
|
return False
|
||||||
except:
|
except:
|
||||||
print(conn)
|
conn.close()
|
||||||
|
return False
|
||||||
|
conn.close()
|
||||||
|
return False
|
||||||
|
|
||||||
def get_user_player(user):
|
def get_user_player(user):
|
||||||
conn = create_connection()
|
conn = create_connection()
|
||||||
|
@ -211,6 +215,8 @@ def save_team(name, team_json_string, user_id):
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
conn.close()
|
||||||
|
return False
|
||||||
|
|
||||||
def update_team(name, team_json_string):
|
def update_team(name, team_json_string):
|
||||||
conn = create_connection()
|
conn = create_connection()
|
||||||
|
@ -225,7 +231,10 @@ def update_team(name, team_json_string):
|
||||||
conn.close()
|
conn.close()
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
|
conn.close()
|
||||||
return False
|
return False
|
||||||
|
conn.close()
|
||||||
|
return False
|
||||||
|
|
||||||
def get_team(name, owner=False):
|
def get_team(name, owner=False):
|
||||||
conn = create_connection()
|
conn = create_connection()
|
||||||
|
@ -258,6 +267,8 @@ def delete_team(team):
|
||||||
except:
|
except:
|
||||||
conn.close()
|
conn.close()
|
||||||
return False
|
return False
|
||||||
|
conn.close()
|
||||||
|
return False
|
||||||
|
|
||||||
def assign_owner(team_name, owner_id):
|
def assign_owner(team_name, owner_id):
|
||||||
conn = create_connection()
|
conn = create_connection()
|
||||||
|
@ -271,6 +282,8 @@ def assign_owner(team_name, owner_id):
|
||||||
except:
|
except:
|
||||||
conn.close()
|
conn.close()
|
||||||
return False
|
return False
|
||||||
|
conn.close()
|
||||||
|
return False
|
||||||
|
|
||||||
def get_all_teams():
|
def get_all_teams():
|
||||||
conn = create_connection()
|
conn = create_connection()
|
||||||
|
|
|
@ -489,7 +489,6 @@ class AssignOwnerCommand(Command):
|
||||||
async def execute(self, msg, command):
|
async def execute(self, msg, command):
|
||||||
new_owner = msg.mentions[0]
|
new_owner = msg.mentions[0]
|
||||||
team_name = command.strip().split(new_owner.mention+" ")[1]
|
team_name = command.strip().split(new_owner.mention+" ")[1]
|
||||||
print(team_name)
|
|
||||||
if db.assign_owner(team_name, new_owner.id):
|
if db.assign_owner(team_name, new_owner.id):
|
||||||
await msg.channel.send(f"{team_name} is now owned by {new_owner.display_name}. Don't break it.")
|
await msg.channel.send(f"{team_name} is now owned by {new_owner.display_name}. Don't break it.")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user