"""Create fixture entries in db.""" import os import mysql.connector cnx = mysql.connector.connect( host=os.environ.get('MYSQL_HOST', '127.0.0.1'), port=os.environ.get('MYSQL_PORT', '18089'), database=os.environ.get('MYSQL_DB', 'royalty_accounting'), user=os.environ.get('MYSQL_USER', 'db_user'), password=os.environ.get('MYSQL_PASS', 'db_pass')) cursor = cnx.cursor() payee_query = """INSERT INTO payee ( payee_id, payee_name, payee_type, payment_agreement_type, currency_code, payment_schedule, payment_minimum, payment_method, created_by, created_at, last_modified_by, last_modified) VALUES (1, 'test', 'Label', 'The Orchard', 'USD', '60 days after month end', 100.00, 'Check', 'test', '2020-08-31 05:04:33', 'test', '2020-08-31 05:04:37')""" cursor.execute(payee_query) cnx.commit() cursor = cnx.cursor() payment_group_query = """INSERT INTO payment_group ( payment_group_id, group_name, group_criteria, is_reusable, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by) VALUES (1, 'test', '{"payee_id": 1}', 0, '2020-08-28 07:11:39', 'test', '2020-08-28 07:11:42', 'test', null, null)""" cursor.execute(payment_group_query) cnx.commit() cursor = cnx.cursor() payment_group_payment_query = """INSERT INTO payment_group_payment ( payment_group_payment_id, payment_group_id, payment_name, payment_status, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by) VALUES (1, 1, 'test', 'approved', '2020-08-28 07:26:44', 'test', '2020-08-28 07:26:49', 'test', null, null)""" cursor.execute(payment_group_payment_query) cnx.commit() cursor = cnx.cursor() payment_group_payment_payee_query = """INSERT INTO payment_group_payment_payee ( payment_group_payment_payee_id, payment_group_payment_id, prior_payment_group_payment_id, payee_id, currency_code, last_payment, current_balance, note, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by) VALUES (1, 1, null, 1, 'USD', 100.00, 200.00, null, '2020-09-02 04:55:20', 'test', '2020-09-02 04:55:28', 'test', null, null)""" cursor.execute(payment_group_payment_payee_query) cnx.commit() cnx.close() print('Fixture entries were inserted')