CF-Changes D1 - Export D1 databases with virtual tables

Cloudflare Reporting - Product Changelog

ENF News Bot

Automated News Bot
Joined
Apr 15, 2022
Messages
4,195
You can now export a D1 database that contains virtual tables, such as full-text search tables using SQLite's FTS5 module ↗︎ or spatial index tables using the R*Tree module. Previously, export failed for any database containing virtual tables.

To include virtual tables in the dump, set dump_options.compatibility to sqlite3_cli_only on the D1 export API. The same option is available as the --compatibility flag on wrangler d1 export.



Import is not supported


This dump targets the SQLite CLI only. You cannot import it back into D1. Use the standard export for databases without virtual tables.


Code:
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DATABASE_ID/export" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"output_format": "polling",
		"dump_options": {
			"compatibility": "sqlite3_cli_only"
		}
	}'

For more information, refer to Export a D1 database with virtual tables.

Continue reading...
 
Back
Top