Skip to content

Instantly share code, notes, and snippets.

@mesmacosta
Created October 25, 2020 18:13
Show Gist options
  • Select an option

  • Save mesmacosta/bef27cb31376f615d6302819f8c1d6e6 to your computer and use it in GitHub Desktop.

Select an option

Save mesmacosta/bef27cb31376f615d6302819f8c1d6e6 to your computer and use it in GitHub Desktop.
def sync(event, context):
"""Sync PostgreSQL metadata with Google Data Catalog
"""
try:
# Log out the message that triggered the function
logging.info('This Function was triggered by messageId {} published at {}'.
format(context.event_id, context.timestamp))
logging.info('Starting sync logic.')
datacatalog_cli.PostgreSQL2DatacatalogCli().run(_get_connector_run_args())
logging.info('Sync execution done.')
return 'ok', 200
except PermissionError as err:
logging.error('Error executing sync: %s', str(err))
return 'authentication denied', 401
except UserWarning as warn:
logging.error('Error executing sync: %s', str(warn))
return str(warn), 400
except Exception as err:
logging.error('Error executing sync: %s', str(err))
return 'failed to sync', 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment