postgresql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(cfg *config.DatabaseConfig, log logger.Logger) (database.Interface, error)

NewConnection creates a new PostgreSQL connection

Types

type Connection

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

Connection implements the database.Interface for PostgreSQL

func (*Connection) Begin

func (c *Connection) Begin(ctx context.Context) (*sql.Tx, error)

Begin starts a transaction

func (*Connection) BeginTx

func (c *Connection) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

BeginTx starts a transaction with options

func (*Connection) Close

func (c *Connection) Close() error

Close closes the database connection

func (*Connection) CreateMigrationTable

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

CreateMigrationTable creates the migration table if it doesn't exist

func (*Connection) DatabaseType

func (c *Connection) DatabaseType() string

DatabaseType returns the database type

func (*Connection) Exec

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

Exec executes a query without returning any rows

func (*Connection) GetMigrationTable

func (c *Connection) GetMigrationTable() string

GetMigrationTable returns the migration table name for PostgreSQL

func (*Connection) Health

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

Health checks database connectivity

func (*Connection) Prepare

func (c *Connection) Prepare(ctx context.Context, query string) (*sql.Stmt, error)

Prepare creates a prepared statement for later queries or executions

func (*Connection) Query

func (c *Connection) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows

func (*Connection) QueryRow

func (c *Connection) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that returns at most one row

func (*Connection) Stats

func (c *Connection) Stats() (map[string]interface{}, error)

Stats returns database connection statistics

Jump to

Keyboard shortcuts

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