"""Misc db_helper methods.""" import mysql.connector def mysqlclient_docker(): """Initialize mysql client for docker image.""" return mysql.connector.connect( host='reserves-release-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) def check_db_empty(compare_func, table='ledger_accounting_run_balance'): """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()