d1sync

package
v0.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package d1sync implements full schema+data sync between a Cloudflare D1 database and a local SQLite file.

  • Pull: D1 → local SQLite (snapshot D1 for local dev / inspection)
  • Push: local SQLite → D1 (seed or restore a D1 database)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pull

func Pull(d1DSN, localPath string, opts PullOptions) error

Pull copies the full contents of a D1 database into a local SQLite file. The local file is created (or overwritten). Only user tables are copied; Cloudflare-internal tables (_cf_*) are skipped.

func Push

func Push(localPath, d1DSN string, opts PushOptions) error

Push copies the full contents of a local SQLite file into a D1 database. Only user tables are pushed; SQLite-internal tables (sqlite_*) are skipped.

Types

type PullOptions

type PullOptions struct {
	// BatchSize is the number of rows fetched per SELECT page (default 500).
	BatchSize int
	// ProgressFn is called after each table is pulled; may be nil.
	ProgressFn func(table string, rows int)
}

PullOptions controls the Pull operation.

type PushOptions

type PushOptions struct {
	// BatchSize is the number of INSERT rows sent per D1 API call (default 100).
	// D1's HTTP API has a 100 statement limit per request.
	BatchSize int
	// DropExisting drops tables in D1 that already exist before recreating them.
	DropExisting bool
	// ProgressFn is called after each table is pushed; may be nil.
	ProgressFn func(table string, rows int)
}

PushOptions controls the Push operation.

type TableData

type TableData struct {
	Name string
	DDL  string
	Rows []map[string]interface{}
}

TableData holds the DDL and rows for one table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL