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

postgres

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

Package postgres implements the sq driver for postgres.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpCatalogCmd added in v0.47.4

func DumpCatalogCmd(src *source.Source, p *ToolParams) (*execz.Cmd, error)

DumpCatalogCmd returns the shell command to execute pg_dump for src. Example output:

pg_dump -Fc -d postgres://alice:vNgR6R@db.acme.com:5432/sales sales.dump

Reference:

See also: RestoreCatalogCmd.

func DumpClusterCmd added in v0.47.4

func DumpClusterCmd(src *source.Source, p *ToolParams) (*execz.Cmd, error)

DumpClusterCmd returns the shell command to execute pg_dumpall for src. Example output (components concatenated with space):

PGPASSWORD=vNgR6R pg_dumpall -w -l sales -d postgres://alice:vNgR6R@db.acme.com:5432/sales -f cluster.dump

Note that the dump produced by pg_dumpall is executed by psql, not pg_restore.

See also: RestoreClusterCmd.

func ExecCmd added in v0.47.4

func ExecCmd(src *source.Source, p *ExecToolParams) (*execz.Cmd, error)

ExecCmd returns the shell command to execute psql with a script file or command string. Example command:

psql -d postgres://alice:vNgR6R@db.acme.com:5432/sales -f query.sql

See: https://www.postgresql.org/docs/9.6/app-psql.html.

func RestoreCatalogCmd added in v0.47.4

func RestoreCatalogCmd(src *source.Source, p *ToolParams) (*execz.Cmd, error)

RestoreCatalogCmd returns the shell command to restore a pg catalog (db) from a dump produced by pg_dump (DumpClusterCmd). Example command:

pg_restore -d postgres://alice:vNgR6R@db.acme.com:5432/sales sales.dump

Reference:

See also: DumpCatalogCmd.

func RestoreClusterCmd added in v0.47.4

func RestoreClusterCmd(src *source.Source, p *ToolParams) (*execz.Cmd, error)

RestoreClusterCmd returns the shell command to restore a pg cluster from a dump produced by pg_dumpall (DumpClusterCmd). Note that the dump produced by pg_dumpall is executed by psql, not pg_restore. Example command:

psql -d postgres://alice:vNgR6R@db.acme.com:5432/sales -f sales.dump

Reference:

See also: DumpClusterCmd.

Types

type ExecToolParams added in v0.47.4

type ExecToolParams struct {
	// ScriptFile is the path to the script file.
	// Only one of ScriptFile or CmdString will be set.
	ScriptFile string

	// CmdString is the literal SQL command string.
	CmdString string

	// Verbose indicates verbose output (progress).
	// Only one of ScriptFile or CmdString will be set.
	Verbose bool

	// LongFlags indicates whether to use long flags, e.g. --file instead of -f.
	LongFlags bool
}

type Provider

type Provider struct {
	Log *slog.Logger
}

Provider is the postgres implementation of driver.Provider.

func (*Provider) DriverFor

func (p *Provider) DriverFor(typ drivertype.Type) (driver.Driver, error)

DriverFor implements driver.Provider.

type ToolParams added in v0.47.4

type ToolParams struct {
	// File is the path to the file.
	File string

	// Verbose indicates verbose output (progress).
	Verbose bool

	// NoOwner won't output commands to set ownership of objects; the source's
	// connection user will own all objects. This also sets the --no-acl flag.
	// Maybe NoOwner should be named "no security" or similar?
	NoOwner bool

	// LongFlags indicates whether to use long flags, e.g. --no-owner instead
	// of -O.
	LongFlags bool
}

ToolParams are parameters for postgres tools such as pg_dump and pg_restore.

- https://www.postgresql.org/docs/9.6/app-pgdump.html - https://www.postgresql.org/docs/9.6/app-pgrestore.html. - https://www.postgresql.org/docs/9.6/app-pg-dumpall.html - https://cloud.google.com/sql/docs/postgres/import-export/import-export-dmp

Not every flag is applicable to all tools.

Jump to

Keyboard shortcuts

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