Skip to main content

Module copy

Module copy 

Source
Expand description

Cross-DB row copy: stream rows from one backend’s table or query into another backend’s table, translating types via the unified Value enum.

The default conflict policy is non-destructive — a copy into a non-empty existing target table errors out before any INSERT (or source SELECT) runs. Callers opt in to Append or Truncate via IfExists.

Structs§

AllTablesOptions
Options for copy_all_tables.
CopyOptions
Options for a copy operation.
CycleError
Error type for topo_sort. Carries the cycle path so callers can surface it in the error message.

Enums§

BulkMode
Whether copy_rows should route INSERT batches through the backend’s native bulk loader.
CopyFormat
Wire format used by the Postgres COPY bulk path.
CopySource
Source side of a copy: a whole table or an arbitrary SELECT.
IfExists
What to do when the target table already exists and is non-empty.

Functions§

copy_all_tables
Copy every table from src to dst in FK-respecting order.
copy_rows
Stream rows from src to dst per opts. Returns the number of rows inserted into the target.
discover_tables
Discover tables on src and apply include/exclude filters. Returns the filtered list in list_tables order (alphabetical for most backends). Caller is expected to feed this into topo_sort before issuing copies.
quote_identifier
Backend-aware identifier quoting:
topo_sort
Topologically sort tables so parents are loaded before children, using fks as the edge set. Tables referenced as parents but not present in tables (e.g. excluded from --all-tables selection) are dropped from the dependency graph.
translate_ddl
Translate source column metadata into a CREATE TABLE IF NOT EXISTS statement for the destination backend.
translate_type
Map a unified TypeHint to a SQL type for the destination backend. The mapping favours portability over fidelity: Decimal collapses to a (38,10) default on backends that need precision, Array stores as a JSON-ish text, and Other/Null fall back to the backend’s “wide string” type.