"""Creates required DB fixtures.""" import mysql.connector cnx = mysql.connector.connect( host='commit-royalties-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.account ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1042518, 'TEST ACCOUNT', 1472, '2021-04-12 02:38:45.000000', 1472, '2021-04-12 02:38:45.000000' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.abacus_event ( abacus_event_id, event_name, target_type, target_id, event_date, previous_abacus_event_id, rolled_back_at ) VALUES ( 1067, 'commit_royalties', 'accounting_run', 1472, '2021-04-12 02:38:45.000000', null, null ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.accounting_run ( accounting_run_id, accounting_period_id, run_controller_id, run_status, start_date, summary_export_url, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1472, 21, 2687, 'Committed', NOW(), "s3://test-royalties-sales-files/accounting-period/accounting-run/fake.tsv", '2107', '2021-04-12 02:40:58', '1952', '2021-04-12 02:41:06' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.accounting_period ( accounting_period_id, statement_period_id, accounting_period_name, accounting_period_status, contract_type, closed_date, created_by, created_at, last_modified_by, last_modified ) VALUES ( 21, 282, 'test', 'open', 'distribution', null, 'vz', '2022-02-16 05:35:39', 'vz', '2022-02-16 05:35:42' );""" cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.abacus_state ( parent_table_id, parent_table_name, action_name, action_status, message, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1472, 'accounting_run', 'commit_royalties', 'init', null, 'rp', '2021-04-12 02:38:45', 'rp', '2021-04-12 02:38:45' ); """ cursor.execute(query) cnx.commit() cnx.close() print('Fixtures were created.')