def table_exists(connection, tablename): try: if get_number_of_rows(connection, tablename) > 0: return True except pymysql.ProgrammingError: return False