123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- from sqlite3 import Cursor
- from game import CURRENCY_NAME, BANK_NAME
- def seed(cursor: Cursor):
- print(' - Seeding initial data...')
- # ₭ollar
- cursor.executemany('''
- INSERT OR IGNORE INTO ownables
- (name)
- VALUES (?)
- ''', [
- (CURRENCY_NAME,),
- ])
- # The bank/external investors
- cursor.execute('''
- INSERT OR IGNORE INTO users
- (username,password)
- VALUES (?,'')
- ''', (BANK_NAME,))
- # bank owns some stuff
- cursor.execute('''
- INSERT OR IGNORE INTO ownership
- (user_id, ownable_id, amount)
- SELECT (SELECT rowid FROM users WHERE username = ?),
- ownables.rowid,
- (SELECT COALESCE(SUM(amount),0) FROM ownership WHERE ownable_id = ownables.rowid)
- FROM ownables
- ''', (BANK_NAME, ))
- cursor.executemany('''
- INSERT INTO global_control_values (value_name, value)
- WITH new_value AS (SELECT ? AS name, ? AS value)
- SELECT new_value.name, new_value.value
- FROM new_value
- WHERE NOT EXISTS(SELECT * -- TODO test if this works
- FROM global_control_values v2
- WHERE v2.value_name = new_value.name
- AND v2.value = new_value.value
- AND v2.dt = (SELECT MAX(v3.dt)
- FROM global_control_values v3
- WHERE v3.value_name = new_value.name
- AND v3.value = new_value.value))
- ''', [('banking_license_price', 5e6),
- ('personal_loan_interest_rate', 0.1), # may seem a lot but actually this is a credit that you get without any assessment involved
- ('deposit_facility', -0.005), # ECB 2020
- ('cash_reserve_ratio', 0.01), # Eurozone 2020
- ('cash_reserve_free_amount', 1e5), # Eurozone 2020
- ('main_refinancing_operations', 0.0000), # ECB 2020
- ])
|