Seed the bank row and its setting
This commit is contained in:
1 parent
6c268e77b2
commit
c48a276062
1 file changed
+15
-1
+15
-1
@@ -86,7 +86,7 @@ def apply_schema(conn=None):
|
|||||||
|
|
||||||
|
|
||||||
def seed_defaults(conn=None):
|
def seed_defaults(conn=None):
|
||||||
"""Insert the default settings and the seeded rates. Idempotent."""
|
"""Insert the default settings, the seeded rates and the bank. Idempotent."""
|
||||||
own = conn is None
|
own = conn is None
|
||||||
if own:
|
if own:
|
||||||
conn = connect()
|
conn = connect()
|
||||||
@@ -101,6 +101,20 @@ def seed_defaults(conn=None):
|
|||||||
" VALUES ('BTC', ?, ?, ?)",
|
" VALUES ('BTC', ?, ?, ?)",
|
||||||
(date, nok_per_btc_ore, SETTING_DEFAULTS["year_end_price_source"]),
|
(date, nok_per_btc_ore, SETTING_DEFAULTS["year_end_price_source"]),
|
||||||
)
|
)
|
||||||
|
# The bank holds no sats and is nobody's holding (section 3.11).
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO markets (name, kind, taxable, archived)"
|
||||||
|
" VALUES (?, ?, 0, 1)",
|
||||||
|
(BANK_NAME, BANK_KIND),
|
||||||
|
)
|
||||||
|
row = conn.execute(
|
||||||
|
"SELECT id FROM markets WHERE name = ?", (BANK_NAME,)
|
||||||
|
).fetchone()
|
||||||
|
if row is not None:
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO settings (key, value) VALUES ('bank_market_id', ?)",
|
||||||
|
(str(row["id"]),),
|
||||||
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
finally:
|
finally:
|
||||||
if own:
|
if own:
|
||||||
|
|||||||
Reference in new issue
Block a user