mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Use meme class
This commit is contained in:
parent
f2b62c3ce7
commit
77addbc30c
2 changed files with 22 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from attr import dataclass
|
||||
|
||||
from functions.database import utils
|
||||
|
||||
|
||||
|
|
@ -18,9 +20,23 @@ def getMeme(name):
|
|||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT * FROM memes WHERE name like %s", ["%" + name.lower() + "%"])
|
||||
result = cursor.fetchall()
|
||||
|
||||
if len(result) == 0:
|
||||
return None
|
||||
return result[0]
|
||||
|
||||
meme = Meme(result[0][0], result[0][1], result[0][2])
|
||||
|
||||
return meme
|
||||
|
||||
|
||||
@dataclass
|
||||
class Meme:
|
||||
"""
|
||||
Dataclass to represent a meme in order to avoid having to use [] on tuples all the time
|
||||
"""
|
||||
meme_id: int
|
||||
name: str
|
||||
fields: int
|
||||
|
||||
|
||||
def getAllMemes():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue