"""Delete foreign keys from ledger tables.""" import mysql.connector cnx = mysql.connector.connect( host='ledger-accounting-run-balance-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) cursor = cnx.cursor() cursor = cnx.cursor() cursor.execute( 'ALTER TABLE ledger_accounting_run_balance DROP FOREIGN KEY fk_abacus_event_ledger;') # noqa: E501 cursor.execute( 'ALTER TABLE ledger_accounting_run_balance DROP FOREIGN KEY fk_accounting_run_ledger;') # noqa: E501 cursor.execute( 'ALTER TABLE ledger_accounting_run_balance DROP FOREIGN KEY fk_contract_ledger;') # noqa: E501 cursor.execute( 'ALTER TABLE accounting_period DROP FOREIGN KEY fk_statement_period_acct_period;') # noqa: E501 cursor.execute( 'ALTER TABLE abacus_event DROP FOREIGN KEY fk_abacus_event_statement_period;') # noqa: E501 cnx.close() print('Foreign keys were deleted from ledger tables')