postgres

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgreSQLAdapter

func NewPostgreSQLAdapter(dsn string) (thing.DBAdapter, error)

NewPostgreSQLAdapter creates a new PostgreSQL adapter instance.

Types

type Adapter

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

PostgreSQLAdapter implements the DBAdapter interface for PostgreSQL.

func (*Adapter) BeginTx

func (a *Adapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (thing.Tx, error)

BeginTx starts a transaction.

func (*Adapter) Builder

func (a *Adapter) Builder() thing.SQLBuilder

Builder returns the SQLBuilder associated with the PostgreSQLAdapter.

func (*Adapter) Close

func (a *Adapter) Close() error

func (*Adapter) DB

func (a *Adapter) DB() *sql.DB

DB returns the underlying *sql.DB for advanced use cases.

func (*Adapter) DialectName

func (a *Adapter) DialectName() string

DialectName returns the name of the database dialect.

func (*Adapter) Exec

func (a *Adapter) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query that doesn't return rows. PostgreSQL uses '$N' placeholders.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get retrieves a single row and scans it into the destination struct. Uses QueryContext and prepares scan destinations based on returned columns. PostgreSQL uses '$N' placeholders.

func (*Adapter) GetCount

func (a *Adapter) GetCount(ctx context.Context, tableName string, where string, args []interface{}) (int64, error)

GetCount executes a SELECT COUNT(*) query. PostgreSQL uses '$N' placeholders.

func (*Adapter) Select

func (a *Adapter) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select executes a query and scans the results into a slice. PostgreSQL uses '$N' placeholders.

type Dialector

type Dialector struct{}

PostgresDialector implements the sqlbuilder.Dialector interface for PostgreSQL.

func (Dialector) Placeholder

func (d Dialector) Placeholder(index int) string

func (Dialector) Quote

func (d Dialector) Quote(identifier string) string

type PostgreSQLIntrospector

type PostgreSQLIntrospector struct {
	DB *sql.DB
}

PostgreSQLIntrospector implements schema.Introspector for PostgreSQL.

func (*PostgreSQLIntrospector) GetTableInfo

func (pi *PostgreSQLIntrospector) GetTableInfo(ctx context.Context, tableName string) (*driversSchema.TableInfo, error)

GetTableInfo introspects the given table and returns its schema info (PostgreSQL).

type Tx

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

PostgreSQLTx implements the Tx interface for PostgreSQL.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) Exec

func (tx *Tx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query within the transaction.

func (*Tx) Get

func (tx *Tx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get executes a query within the transaction.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rolls back the transaction.

func (*Tx) Select

func (tx *Tx) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select executes a query within the transaction.

Jump to

Keyboard shortcuts

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