forked from brmlab/brmbar-github
brmbar.Currency.update_{sell,buy}_rate(): New methods
This commit is contained in:
parent
e6588a5eba
commit
fedd1ecd50
1 changed files with 7 additions and 0 deletions
|
@ -76,3 +76,10 @@ class Currency:
|
||||||
|
|
||||||
def str(self, amount):
|
def str(self, amount):
|
||||||
return "{:.2f} {}".format(amount, self.name)
|
return "{:.2f} {}".format(amount, self.name)
|
||||||
|
|
||||||
|
def update_sell_rate(self, target, rate):
|
||||||
|
with closing(self.db.cursor()) as cur:
|
||||||
|
cur.execute("INSERT INTO exchange_rates (source, target, rate, rate_dir) VALUES (%s, %s, %s, %s)", [self.id, target.id, rate, "source_to_target"])
|
||||||
|
def update_buy_rate(self, source, rate):
|
||||||
|
with closing(self.db.cursor()) as cur:
|
||||||
|
cur.execute("INSERT INTO exchange_rates (source, target, rate, rate_dir) VALUES (%s, %s, %s, %s)", [source.id, self.id, rate, "target_to_source"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue