"""Creates required DB fixtures.""" import mysql.connector cnx = mysql.connector.connect( host='commit-mechanicals-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 ( 46443, 'TEST ACCOUNT 1', 1472, '2021-04-12 02:38:45.000000', 1472, '2021-04-12 02:38:45.000000' ), ( 56158, 'TEST ACCOUNT 2', 1472, '2021-04-12 02:38:45.000000', 1472, '2021-04-12 02:38:45.000000' ), ( 72835, 'TEST ACCOUNT 3', 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.contract ( contract_id, reference_signing_entity_id, reference_sap_profit_center_id, contract_name, contract_type, term_start, term_end, created_by, created_at, last_modified_by, last_modified ) VALUES ( 532855, 1, 1, 'test 1', 'distribution', '2022-06-06', '2022-06-09', 'vz', '2022-06-06 03:43:02', 'vz', '2022-06-06 03:43:05' ), ( 531600, 1, 1, 'test 2', 'distribution', '2022-06-06', '2022-06-09', 'vz', '2022-06-06 03:43:02', 'vz', '2022-06-06 03:43:05' ), ( 532342, 1, 1, 'test 3', 'distribution', '2022-06-06', '2022-06-09', 'vz', '2022-06-06 03:43:02', 'vz', '2022-06-06 03:43:05' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """INSERT INTO royalty_accounting.account_contract ( account_contract_id, account_id, contract_id ) VALUES ( 1, 46443, 532855 ), ( 2, 56158, 531600 ), ( 3, 72835, 532342 ); """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.abacus_event ( abacus_event_id, statement_period_id, event_name, target_type, target_id, event_date, previous_abacus_event_id, rolled_back_at ) VALUES ( 1, 282, 'commit_mechanicals', 'accounting_run', 195, '2021-04-12 02:38:45.000000', null, null ) """ 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.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 ( 195, 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() cnx.close() print('Fixtures were created.')