postgres

package
v0.0.0-...-bd113ff Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterUnsupported = dio.FilterUnsupported
	FilterExact       = dio.FilterExact
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

func (*Connection) Close

func (c *Connection) Close(ctx context.Context) error

func (*Connection) Conn

func (c *Connection) Conn() *pgx.Conn

Conn returns the underlying pgx connection.

func (*Connection) Query

func (c *Connection) Query(ctx context.Context, query string) (dio.Reader, error)

func (*Connection) QueryRow

func (c *Connection) QueryRow(ctx context.Context, query string) platform.Row

type ConnectionConfig

type ConnectionConfig struct {
	Name               string
	User               string
	Host               string
	Port               string
	SSLMode            string
	ConnectionTimeout  int
	Password           string
	SSLCertPath        string
	SSLKeyPath         string
	SSLRootCertPath    string
	PoolMinConnections string
	PoolMaxConnections string
	PoolMaxConnLife    time.Duration
	PoolMaxConnIdle    time.Duration
	PoolHealthCheck    time.Duration
}

ConnectionConfig represents a configuration for a connection to a Postgres database.

func StartTestDB

func StartTestDB(t *testing.T) ConnectionConfig

func (ConnectionConfig) ConnectionString

func (c ConnectionConfig) ConnectionString() string

ConnectionString returns a connection string suitable for the pgx Postgres driver.

type FilterSupport

type FilterSupport = dio.FilterSupport

FilterSupport re-exports dio.FilterSupport constants for use within this package.

type Platform

type Platform struct{}

func (*Platform) OpenConnection

func (p *Platform) OpenConnection(ctx context.Context, cfg platform.ConnectionConfig) (platform.Connection, error)

type PostgresContainer

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

func NewPostgresContainer

func NewPostgresContainer(t *testing.T) *PostgresContainer

func (*PostgresContainer) Close

func (db *PostgresContainer) Close(t *testing.T)

func (*PostgresContainer) ConnectionConfig

func (db *PostgresContainer) ConnectionConfig(t *testing.T) ConnectionConfig

func (*PostgresContainer) Port

func (db *PostgresContainer) Port(t *testing.T) int

type QueryReader

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

QueryReader implements dio.Reader for a postgres query result. Query execution is deferred until Read() is called, allowing filters to be pushed down as SQL WHERE clauses.

func (*QueryReader) ClassifyFilters

func (q *QueryReader) ClassifyFilters(filters []dio.Filter) []FilterSupport

ClassifyFilters reports that all supported filter types are evaluated exactly by postgres (WHERE clause pushdown guarantees all returned rows satisfy the filter).

func (*QueryReader) Read

func (q *QueryReader) Read(ctx context.Context, opts ...dio.ReadOption) (dio.BatchStream, error)

Read executes the query and opens a BatchStream over the result rows. If filters are provided via WithFilter, they are pushed down as a SQL WHERE clause. Second call returns an empty stream (read-once semantics matching DB cursor nature).

func (*QueryReader) Schema

func (q *QueryReader) Schema() *arrow.Schema

Schema returns the Arrow schema derived from the query result columns.

type Writer

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

Writer implements dio.Writer by inserting Arrow data into a postgres table via CopyFrom.

func NewWriter

func NewWriter(conn *Connection, opts WriterOpts) *Writer

NewWriter creates a postgres Writer.

func (*Writer) Close

func (w *Writer) Close() error

Close is a no-op for the postgres writer (connection lifecycle is managed externally).

func (*Writer) WriteStream

func (w *Writer) WriteStream(ctx context.Context, s dio.BatchStream) error

WriteStream writes all records from the stream into the postgres table using CopyFrom.

type WriterOpts

type WriterOpts struct {
	TableName   string
	ColumnNames []string
}

WriterOpts configures a postgres Writer.

Jump to

Keyboard shortcuts

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