def SqlExportContext(sql_messages, uri, database=None, table=None):
  """Generates the ExportContext for the given args, for exporting to SQL.

  Args:
    sql_messages: module, The messages module that should be used.
    uri: The URI of the bucket to export to; the output of the 'uri' arg.
    database: The list of databases to export from; the output of the
        '--database' flag.
    table: The list of tables to export from; the output of the '--table' flag.

  Returns:
    ExportContext, for use in InstancesExportRequest.exportContext.
  """
  return sql_messages.ExportContext(
      uri=uri,
      databases=database or [],
      fileType='SQL',
      sqlExportOptions=sql_messages.ExportContext.SqlExportOptionsValue(
          tables=table or []))