mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 13:24:01 +02:00
#6: new currency stored function
This commit is contained in:
parent
8f42145bee
commit
9235607d4c
3 changed files with 54 additions and 3 deletions
|
@ -42,7 +42,7 @@ class Account:
|
|||
""" 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("SELECT public.create_account(%s, %s, %s)", [name, currency.id, acctype])
|
||||
id = id[0]
|
||||
# id = id[0]
|
||||
return cls(db, name = name, id = id, currency = currency, acctype = acctype)
|
||||
|
||||
def balance(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue