MCPcopy
hub / github.com/jackc/pgx / CopyFrom

Method CopyFrom

copy_from.go:265–276  ·  view source on GitHub ↗

CopyFrom uses the PostgreSQL copy protocol to perform bulk data insertion. It returns the number of rows copied and an error. CopyFrom requires all values use the binary format. A pgtype.Type that supports the binary format must be registered for the type of each column. Almost all types implemente

(ctx context.Context, tableName Identifier, columnNames []string, rowSrc CopyFromSource)

Source from the content-addressed store, hash-verified

263// Even though enum types appear to be strings they still must be registered to use with [Conn.CopyFrom]. This can be done with
264// [Conn.LoadType] and [pgtype.Map.RegisterType].
265func (c *Conn) CopyFrom(ctx context.Context, tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int64, error) {
266 ct := &copyFrom{
267 conn: c,
268 tableName: tableName,
269 columnNames: columnNames,
270 rowSrc: rowSrc,
271 readerErrChan: make(chan error),
272 mode: c.config.DefaultQueryExecMode,
273 }
274
275 return ct.run(ctx)
276}

Callers

nothing calls this directly

Calls 1

runMethod · 0.95

Tested by

no test coverage detected