#6: new currency stored function

This commit is contained in:
Dominik Pantůček 2025-04-20 19:15:23 +02:00
parent 8f42145bee
commit 9235607d4c
3 changed files with 54 additions and 3 deletions

View file

@ -31,8 +31,9 @@ class Currency:
@classmethod
def create(cls, db, name):
""" Constructor for new currency """
id = db.execute_and_fetch("INSERT INTO currencies (name) VALUES (%s) RETURNING id", [name])
id = id[0]
# id = db.execute_and_fetch("INSERT INTO currencies (name) VALUES (%s) RETURNING id", [name])
id = db.execute_and_fetch("SELECT public.create_currency(%s)", [name])
# id = id[0]
return cls(db, name = name, id = id)
def rates(self, other):