Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 838 Bytes

File metadata and controls

43 lines (32 loc) · 838 Bytes

Import and Export

Import

ImportSQL handles the full flow:

  1. MD5 etag calculation.
  2. Import init.
  3. SQL upload to presigned URL.
  4. Import ingest.
  5. Poll until complete.
data, err := os.ReadFile("dump.sql")
res, err := client.ImportSQL(ctx, "", data, 2*time.Second)

Manual flow:

etag := d1http.MD5Hex(data)
initRes, err := client.InitImport(ctx, "", etag)
err = client.UploadImportSQL(ctx, initRes.UploadURL, data)
ingestRes, err := client.IngestImport(ctx, "", etag)

Export

res, err := client.ExportUntilComplete(ctx, "", d1http.ExportRequest{
    OutputFormat: "polling",
}, 2*time.Second)

Schema-only:

res, err := client.ExportUntilComplete(ctx, "", d1http.ExportRequest{
    OutputFormat: "polling",
    DumpOptions: &d1http.DumpOptions{NoData: true},
}, 2*time.Second)