pgutil

package
v0.31.10 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package pgutil contains utilities for postgres

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckApplicationName

func CheckApplicationName(s string) (r string)

CheckApplicationName ensures that the Connection String contains an application name

func ConnstrWithSchema

func ConnstrWithSchema(connstr, schema string) string

ConnstrWithSchema adds schema to a connection string

func CreateRandomTestingSchemaName

func CreateRandomTestingSchemaName(n int) string

CreateRandomTestingSchemaName creates a random schema name string.

func CreateSchema

func CreateSchema(ctx context.Context, db Execer, schema string) (err error)

CreateSchema creates a schema if it doesn't exist.

func DropSchema

func DropSchema(ctx context.Context, db Execer, schema string) error

DropSchema drops the named schema

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError checks if given error is about constraint violation

func OpenUnique added in v0.27.0

func OpenUnique(ctx context.Context, connstr string, schemaPrefix string) (*dbutil.TempDatabase, error)

OpenUnique opens a postgres database with a temporary unique schema, which will be cleaned up when closed. It is expected that this should normally be used by way of "storj.io/storj/private/dbutil/tempdb".OpenUnique() instead of calling it directly.

func ParseSchemaFromConnstr

func ParseSchemaFromConnstr(connstr string) (string, error)

ParseSchemaFromConnstr returns the name of the schema parsed from the connection string if one is provided

func QueryData

func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error)

QueryData loads all data from tables

func QuerySchema

func QuerySchema(ctx context.Context, db dbschema.Queryer) (*dbschema.Schema, error)

QuerySchema loads the schema from postgres database.

func QuerySnapshot

func QuerySnapshot(ctx context.Context, db dbschema.Queryer) (*dbschema.Snapshot, error)

QuerySnapshot loads snapshot from database

func QuoteSchema

func QuoteSchema(schema string) string

QuoteSchema quotes schema name for

func UnquoteIdentifier added in v0.27.0

func UnquoteIdentifier(quotedIdent string) string

UnquoteIdentifier is the analog of pq.QuoteIdentifier.

Types

type Execer

type Execer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

Execer is for executing sql

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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