Skip to content
Home » D1Admin Documentation » Exporting Data from D1

Exporting Data from D1

Export and Import of a database is a convenient way to transfer a data from one system to another. This tutorial describes the tools for Exporting and Importing part or whole Cloudflare D1 database as SQL or CSV (comma separated values) files.

Exporting a whole D1 database
Exporting one or several tables
Importing data

Exporting a whole D1 database

We can export a whole Cloudflare D1 database linked with D1Admin through the Export tab:

exporting data from Cloudflare D1

The settings hat we can apply to the exported data is the data format: SQL or CSV (comma separated values) and we can also select what parts of the D1 database to be exported (for SQL format export only): structure, data, comments.

Selecting the desired export format and the destination export file and clicking on the Export button, we will receive a dump file containing:

  • for SQL format: SQL statements, which later on can be imported again into the same or a new Cloudflare D1 database.
  • for CSV format: file containing each selected database table, with first line being list of columns names and each subsequent line containing the table rows in the same order. The CSV format is convenient for post processing the data in other systems like Excel or Google Sheets.

Exporting single Table

Exporting a single table or (set of tables) can be done by selecting only the table(s) that we want to Export and then following the same process as when exporting the whole D1 database.

Importing data from export file

When we have an exported D1 database, we can later on import it back in another D1 database by selecting the Import tab.

Importing D1 database

What we have to choose here is the format of the imported file (SQL or CSV) and the file itself.

In real world scenarios only the SQL format is usable for recreating and importing a database from one location to another. The CSV format doesn’t contain table names, indexes, foreign keys, etc. and thus we cannot replicate the database structure with it.