fix: refactored new_guild_generation

This commit is contained in:
Seaswimmer 2023-08-01 18:03:45 -04:00
parent b0c32a130b
commit 53d1d20942
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -34,18 +34,13 @@ class SugonCredit(commands.Cog):
return word + 's' return word + 's'
def new_guild_generation(self, guild_id): def new_guild_generation(self, guild_id):
"""Adds a new table for a guild to the SQLite databse.""" """Adds a new table for a guild to the SQLite database."""
con = sqlite3.connect(f'{self.data_path}') con = sqlite3.connect(self.data_path)
cur = con.cursor() cur = con.cursor()
exist_check = cur.execute(f'''IF EXISTS try:
(SELECT object_id FROM sys.tables cur.execute(f"SELECT 1 FROM {guild_id} LIMIT 1;")
WHERE name = '{guild_id}' except sqlite3.OperationalError:
AND SCHEMA_NAME(schema_id) = 'dbo') cur.execute(f"CREATE TABLE {guild_id} (user_id TEXT, balance REAL);")
PRINT 'False'
ELSE
PRINT 'True';''')
if exist_check == False:
cur.execute(f'''CREATE TABLE '{guild_id}' (user_id text, balance real)''')
con.commit() con.commit()
con.close() con.close()