## Export D1 Database as SQL `d1.database.export(strdatabase_id, DatabaseExportParams**kwargs) -> DatabaseExportResponse` **post** `/accounts/{account_id}/d1/database/{database_id}/export` Returns a URL where the SQL contents of your D1 can be downloaded. Note: this process may take some time for larger DBs, during which your D1 will be unavailable to serve queries. To avoid blocking your DB unnecessarily, an in-progress export must be continually polled or will automatically cancel. ### Parameters - `account_id: str` Account identifier tag. - `database_id: str` D1 database identifier (UUID). - `output_format: Literal["polling"]` Specifies that you will poll this endpoint until the export completes - `"polling"` - `current_bookmark: Optional[str]` To poll an in-progress export, provide the current bookmark (returned by your first polling response) - `dump_options: Optional[DumpOptions]` - `no_data: Optional[bool]` Export only the table definitions, not their contents - `no_schema: Optional[bool]` Export only each table's contents, not its definition - `tables: Optional[SequenceNotStr[str]]` Filter the export to just one or more tables. Passing an empty array is the same as not passing anything and means: export all tables. ### Returns - `class DatabaseExportResponse: …` - `at_bookmark: Optional[str]` The current time-travel bookmark for your D1, used to poll for updates. Will not change for the duration of the export task. - `error: Optional[str]` Only present when status = 'error'. Contains the error message. - `messages: Optional[List[str]]` Logs since the last time you polled - `result: Optional[Result]` Only present when status = 'complete' - `filename: Optional[str]` The generated SQL filename. - `signed_url: Optional[str]` The URL to download the exported SQL. Available for one hour. - `status: Optional[Literal["complete", "error"]]` - `"complete"` - `"error"` - `success: Optional[bool]` - `type: Optional[Literal["export"]]` - `"export"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.d1.database.export( database_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", account_id="023e105f4ecef8ad9ca31a8372d0c353", output_format="polling", ) print(response.at_bookmark) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "at_bookmark": "at_bookmark", "error": "error", "messages": [ "string" ], "result": { "filename": "filename", "signed_url": "signed_url" }, "status": "complete", "success": true, "type": "export" }, "success": true } ```