I have a simple function to determine whether a table exists or not:
def check_users_usersmetadata_existence():
"""
Checks if the table Prod_UserUserMetadata exists
"""
app_id = get_app_id()
bigquery_client = bigquery.Client(project=app_id)
dataset_ref = bigquery_client.dataset('Backup')
table_ref = dataset_ref.table('Prod_UserUserMetadata')
try:
table = bigquery_client.get_table(table_ref)
if table:
print('Table {}\'s existence sucessfully proved!'.format(table_ref))
return True
except HttpError as error:
raise
print('Whoops! Table {} doesn\'t exist here! Ref: {}'.format(table_ref, error.resp.status))
return False
Problem is, it throws a 404 on this line table = bigquery_client.get_table(table_ref) which is ok because the table shouldn't exist. But it won't continue to process the rest of the script. I'm trying to parse it inside a try except wrapper however it's not working. How would I parse this?