db

package
v1.40.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const PostgresPrefix = "postgres://"

PostgresPrefix is the DSN scheme that routes to the hosted Postgres path.

View Source
const (
	UniqueViolation = "23505"
)

Variables

This section is empty.

Functions

func CheckForeignKeyViolation

func CheckForeignKeyViolation(err error) bool

func CheckNotUnique

func CheckNotUnique(err error) bool

func MigrationDSN added in v1.40.1

func MigrationDSN(dsn string) string

MigrationDSN defaults sslmode to "disable" when a Postgres DSN doesn't set one, so the migration driver (lib/pq, which defaults to "require") can reach the local/compose database. The runtime pool keeps pgx's own "prefer" default. DSNs that are non-Postgres, malformed, or carry an unparseable query are returned untouched.

Types

type OpenFunc

type OpenFunc func(driverName, dataSourceName string) (*sql.DB, error)

OpenFunc is a type for functions that open a database connection.

type Option

type Option func(*SQL)

Option -.

func ConnAttempts

func ConnAttempts(attempts int) Option

ConnAttempts -.

func ConnTimeout

func ConnTimeout(timeout time.Duration) Option

ConnTimeout -.

func EnableForeignKeys

func EnableForeignKeys(value bool) Option

EnableForeignKeys -.

func MaxPoolSize

func MaxPoolSize(size int) Option

MaxPoolSize -.

type SQL

type SQL struct {
	Builder    squirrel.StatementBuilderType
	Pool       *sql.DB
	IsEmbedded bool
	// contains filtered or unexported fields
}

SQL -.

func New

func New(url string, dbOpen OpenFunc, opts ...Option) (*SQL, error)

New -.

func (*SQL) Close

func (p *SQL) Close()

Close -.

Jump to

Keyboard shortcuts

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