"""Helper methods for db interactions.""" import mysql.connector def mysqlclient_docker(): """Initialize mysql client for docker image.""" return mysql.connector.connect( host='payoneer-payments-payout-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) def check_db(compare_func, table='payment_group_payment_batch'): """Check whether table is empty.""" cnx = mysqlclient_docker() cursor = cnx.cursor() cursor.execute('SELECT * FROM {}'.format(table)) cursor.fetchall() rc = cursor.rowcount assert compare_func(rc, 0) cursor.close() cnx.close()