#3: create account in SQL not in Python.

This commit is contained in:
Dominik Pantůček 2025-04-20 17:42:12 +02:00
parent 111a8c9b63
commit c5d1fc3402
3 changed files with 57 additions and 1 deletions

View file

@ -40,7 +40,8 @@ class Account:
@classmethod
def create(cls, db, name, currency, acctype):
""" Constructor for new account """
id = db.execute_and_fetch("INSERT INTO accounts (name, currency, acctype) VALUES (%s, %s, %s) RETURNING id", [name, currency.id, acctype])
# id = db.execute_and_fetch("INSERT INTO accounts (name, currency, acctype) VALUES (%s, %s, %s) RETURNING id", [name, currency.id, acctype])
id = db.execute_and_fetch("SELECT public.create_account(%s, %s, %s)", [name, currency.id, acctype])
id = id[0]
return cls(db, name = name, id = id, currency = currency, acctype = acctype)