Documentation ¶
Index ¶
- Constants
- func NewPostgreSQL(dsn string) (sqldatabase.Engine, error)
- type PostgreSQL
- func (p PostgreSQL) Close() error
- func (p PostgreSQL) Dialect() string
- func (p PostgreSQL) Query(ctx context.Context, query string, args ...any) ([]string, [][]string, error)
- func (p PostgreSQL) TableInfo(ctx context.Context, table string) (string, error)
- func (p PostgreSQL) TableNames(ctx context.Context) ([]string, error)
Constants ¶
const EngineName = "pgx"
Variables ¶
This section is empty.
Functions ¶
func NewPostgreSQL ¶
func NewPostgreSQL(dsn string) (sqldatabase.Engine, error)
NewPostgreSQL creates a new PostgreSQL engine instance. The dsn parameter is the data source name (e.g. postgres://db_user:mysecretpassword@localhost:5438/test?sslmode=disable). It returns a sqldatabase.Engine and an error, if any.
Types ¶
type PostgreSQL ¶
type PostgreSQL struct {
// contains filtered or unexported fields
}
PostgreSQL represents the PostgreSQL engine.
func (PostgreSQL) Close ¶
func (p PostgreSQL) Close() error
Close closes the connection to the PostgreSQL database. It returns an error, if any.
func (PostgreSQL) Dialect ¶
func (p PostgreSQL) Dialect() string
Dialect returns the dialect of the PostgreSQL engine.
func (PostgreSQL) Query ¶
func (p PostgreSQL) Query(ctx context.Context, query string, args ...any) ([]string, [][]string, error)
Query executes a query on the PostgreSQL engine. It takes a context.Context, a query string, and optional query arguments. It returns the column names, query results as a 2D slice of strings, and an error, if any.
func (PostgreSQL) TableInfo ¶
TableInfo returns information about a specific table in the PostgreSQL database. It takes a context.Context and the name of the table. It returns the table name and an error, if any.
func (PostgreSQL) TableNames ¶
func (p PostgreSQL) TableNames(ctx context.Context) ([]string, error)
TableNames returns the names of all tables in the PostgreSQL database. It takes a context.Context. It returns a slice of table names and an error, if any.