> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Import & Export Databases

> Import and export database metadata as CSV

# Import & Export

Export database metadata (schemas, tables, owners, tags) to CSV and import changes back. Supports both synchronous and asynchronous operations.

## Export to CSV

`GET /v1/databases/name/{fqn}/export`

<ParamField path="fqn" type="string" required>
  Fully qualified name of the database (e.g., `snowflake_prod.analytics`).
</ParamField>

## Export Async

`GET /v1/databases/name/{fqn}/exportAsync`

Returns a job ID for large exports that can be polled for completion.

## Import from CSV

`PUT /v1/databases/name/{fqn}/import`

<ParamField path="fqn" type="string" required>
  Fully qualified name of the database.
</ParamField>

<ParamField query="dryRun" type="boolean" default="true">
  If `true`, validates the CSV without applying changes. Set to `false` to apply.
</ParamField>

## Import Async

`PUT /v1/databases/name/{fqn}/importAsync`

For large imports, use the async variant which returns a job ID.

<RequestExample dropdown>
  ```python GET /v1/databases/name/{fqn}/export theme={null}
  from metadata.sdk import configure
  from metadata.sdk.entities import Databases

  configure(
      host="https://your-company.open-metadata.org/api",
      jwt_token="your-jwt-token"
  )

  # Synchronous export
  csv_data = Databases.export_csv("snowflake_prod.analytics").execute()
  print(csv_data)

  # Async export
  job = Databases.export_csv("snowflake_prod.analytics").execute_async()
  print(f"Export job: {job}")

  # Synchronous import (dry run first)
  result = (
      Databases.import_csv("snowflake_prod.analytics")
      .with_data(csv_data)
      .set_dry_run(True)
      .execute()
  )
  print(f"Dry run result: {result}")

  # Apply the import
  result = (
      Databases.import_csv("snowflake_prod.analytics")
      .with_data(csv_data)
      .set_dry_run(False)
      .execute()
  )

  # Async import
  result = (
      Databases.import_csv("snowflake_prod.analytics")
      .with_data(csv_data)
      .set_dry_run(False)
      .execute_async()
  )
  ```

  ```java GET /v1/databases/name/{fqn}/export theme={null}
  import org.openmetadata.sdk.fluent.Databases;

  // Synchronous export
  String csvData = Databases.exportCsv("snowflake_prod.analytics")
      .execute();

  // Async export
  String jobId = Databases.exportCsv("snowflake_prod.analytics")
      .async()
      .execute();

  // Synchronous import (dry run)
  String result = Databases.importCsv("snowflake_prod.analytics")
      .withData(csvData)
      .dryRun(true)
      .execute();

  // Apply import
  String result = Databases.importCsv("snowflake_prod.analytics")
      .withData(csvData)
      .dryRun(false)
      .execute();

  // Async import
  String jobId = Databases.importCsv("snowflake_prod.analytics")
      .withData(csvData)
      .dryRun(false)
      .async()
      .execute();
  ```

  ```bash GET /v1/databases/name/{fqn}/export theme={null}
  # Export to CSV
  curl "{base_url}/api/v1/databases/name/mysql_sample.default/export" \
    -H "Authorization: Bearer {access_token}"

  # Async export
  curl "{base_url}/api/v1/databases/name/mysql_sample.default/exportAsync" \
    -H "Authorization: Bearer {access_token}"

  # Import CSV (dry run)
  curl -X PUT "{base_url}/api/v1/databases/name/mysql_sample.default/import?dryRun=true" \
    -H "Authorization: Bearer {access_token}" \
    -H "Content-Type: text/plain" \
    --data-binary @database_export.csv

  # Import CSV (apply)
  curl -X PUT "{base_url}/api/v1/databases/name/mysql_sample.default/import?dryRun=false" \
    -H "Authorization: Bearer {access_token}" \
    -H "Content-Type: text/plain" \
    --data-binary @database_export.csv

  # Async import
  curl -X PUT "{base_url}/api/v1/databases/name/mysql_sample.default/importAsync?dryRun=false" \
    -H "Authorization: Bearer {access_token}" \
    -H "Content-Type: text/plain" \
    --data-binary @database_export.csv
  ```
</RequestExample>

<ResponseExample>
  ```json Response (Export) theme={null}
  "name,displayName,description,owner,tags,retentionPeriod,sourceUrl,domain\nposts_db,posts_db,,,,,https://localhost:3306/posts_db,"
  ```
</ResponseExample>

***

## Returns

**Export** returns CSV text with headers and rows for each child entity.

**Import** returns a summary of changes applied (or validation results for dry run).

***

## Error Handling

| Code  | Error Type     | Description                             |
| ----- | -------------- | --------------------------------------- |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN`    | User lacks permission for import/export |
| `404` | `NOT_FOUND`    | Database with given FQN does not exist  |
| `400` | `BAD_REQUEST`  | Invalid CSV format or content           |
