def create_export_context(schema_type: SchemaType, export_uri: str, export_query: str) -> dict: """Creates the exportContext configuration for the export operation. See here for details: https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances/export Args: schema_type: The schema, either SchemaType.JAILS or SchemaType.STATE of the table being exported. export_uri: GCS URI to write the exported CSV data to. export_query: SQL query defining the data to be exported. Returns: export_context dict which can be passed to client.instances.export(). """ export_context = { 'exportContext': { 'kind': 'sql#exportContext', 'fileType': 'CSV', 'uri': export_uri, 'databases': [SQLAlchemyEngineManager.get_db_name(schema_type)], 'csvExportOptions': { 'selectQuery': export_query } } } return export_context
def create_export_context( schema_type: SchemaType, export_uri: str, export_query: str ) -> dict: """Creates the exportContext configuration for the export operation. See here for details: https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances/export Args: schema_type: The SchemaType of the table being exported. export_uri: GCS URI to write the exported CSV data to. export_query: SQL query defining the data to be exported. Returns: export_context dict which can be passed to client.instances.export(). """ export_context = { "exportContext": { "kind": "sql#exportContext", "fileType": "CSV", "uri": export_uri, "databases": [SQLAlchemyEngineManager.get_db_name(schema_type)], "csvExportOptions": {"selectQuery": export_query}, } } return export_context