From fedd1ecd50ffb5d7ac8391ce44844b2f1706baea Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 28 Sep 2012 22:36:30 +0200 Subject: [PATCH] brmbar.Currency.update_{sell,buy}_rate(): New methods --- brmbar3/brmbar/Currency.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/brmbar3/brmbar/Currency.py b/brmbar3/brmbar/Currency.py index e5bdccc..0bb376d 100644 --- a/brmbar3/brmbar/Currency.py +++ b/brmbar3/brmbar/Currency.py @@ -76,3 +76,10 @@ class Currency: def str(self, amount): 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"])