postgresql

package
v0.0.0-...-56865d5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
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

func (p PostgreSQL) TableInfo(ctx context.Context, table string) (string, error)

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.

Jump to

Keyboard shortcuts

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