client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort = 5432
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client = sqltest.Client

Client represents a client for PostgreSQL server.

func NewDefaultClient

func NewDefaultClient() Client

NewDefaultClient returns a default client for PostgreSQL server.

func NewPgxClient

func NewPgxClient() Client

NewPgxClient returns a Pgx client instance.

type Config

type Config struct {
	Host     string
	Port     int
	Database string
}

Config stores server configuration parammeters.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a default configuration instance.

func (*Config) SetDatabase

func (config *Config) SetDatabase(db string)

SetDatabase sets a host database.

func (*Config) SetHost

func (config *Config) SetHost(host string)

SetHost sets a host address.

func (*Config) SetPort

func (config *Config) SetPort(port int)

SetPort sets a listen port.

type PgxClient

type PgxClient struct {
	*Config
	*pgx.Conn
}

PgxClient represents a client for PostgreSQL server.

func (*PgxClient) Close

func (client *PgxClient) Close() error

Close closes the opened database.

func (*PgxClient) CreateDatabase

func (client *PgxClient) CreateDatabase(name string) error

CreateDatabase creates a specified database.

func (*PgxClient) DropDatabase

func (client *PgxClient) DropDatabase(name string) error

DropDatabase dtops a specified database.

func (*PgxClient) Open

func (client *PgxClient) Open() error

Open opens a database specified by the client.

func (*PgxClient) Query

func (client *PgxClient) Query(query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows.

func (*PgxClient) Use

func (client *PgxClient) Use(name string) error

Use sets a target database.

Jump to

Keyboard shortcuts

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