Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package postgres is a dfetch Connector backed by a PostgreSQL database over database/sql (jackc/pgx). It is a dynamic source: rather than declaring tables up front it lists/describes them on demand from information_schema, and it pushes a real SELECT (filters, ordering, LIMIT, and column projection) to the server. One connector maps one Postgres schema (default "public"); expose more schemas by registering more sources. It is config-only — there is no default DSN — so it is registered for `type: postgres` but never auto-instantiated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(params map[string]any) (source.Connector, error)

New builds a Postgres connector. The DSN comes from params["dsn"], else $DFETCH_POSTGRES_DSN or $DATABASE_URL, else params "dsn_func"/"dsn_command" (see source.Credential); it is resolved — and the pool opened — on first use, so a missing DSN errors when a postgres table is queried, not at construction. Other params: "schema" (default "public") and "max_rows" (cap on an un-pushable-LIMIT scan; default 100000). It is config-only — registered for `type: postgres`, never auto-instantiated.

Types

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector queries one schema of a PostgreSQL database.

func (*Connector) DescribeTable

func (c *Connector) DescribeTable(ctx context.Context, table string) (source.TableSchema, bool, error)

DescribeTable resolves one table's columns from information_schema. found is false (nil error) when the table does not exist in the connector's schema.

func (*Connector) ListTables

func (c *Connector) ListTables(ctx context.Context, opts source.ListOptions) ([]string, error)

ListTables returns the base table and view names in the connector's schema, optionally filtered by a case-insensitive substring.

func (*Connector) Scan

func (c *Connector) Scan(ctx context.Context, req source.ScanRequest, emit func(*source.Rows) error) error

Scan runs the pushed-down SELECT and emits rows in batches.

func (*Connector) Tables

func (c *Connector) Tables() []source.TableSchema

Tables returns nil: tables are discovered on demand (ListTables/DescribeTable).

Jump to

Keyboard shortcuts

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