WIP: Moderation type registry #26
1 changed files with 3 additions and 1 deletions
|
@ -31,13 +31,15 @@ class Moderation(BaseModel):
|
|||
def from_sql(cls, moderation_id: int, guild: Guild):
|
||||
query = f"SELECT * FROM moderation_{guild.id} WHERE moderation_id = ?;"
|
||||
|
||||
with connect() as database, database.cursor() as cursor:
|
||||
with connect() as database:
|
||||
cursor = database.cursor()
|
||||
cursor.execute(query, (moderation_id,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if result:
|
||||
moderation_data = dict(zip(cls.model_fields, result))
|
||||
moderation = cls(**moderation_data)
|
||||
cursor.close()
|
||||
return moderation
|
||||
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue