connection

package
v2.6.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package connection contains the PGSQLConnection type and methods for manipulating and querying a PostgreSQL connection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info interface {
	NewConnection(database string) (*PGSQLConnection, error)
	HostPort() (string, string)
	DatabaseName() string
}

Info holds all the information needed from the user to create a new connection

func DefaultConnectionInfo

func DefaultConnectionInfo(al *args.ArgumentList) Info

DefaultConnectionInfo takes an argument list and constructs a default connection out of it

type MockInfo

type MockInfo struct {
	mock.Mock
}

MockInfo is a mock struct which implements connection.Info

func (*MockInfo) DatabaseName

func (mi *MockInfo) DatabaseName() string

DatabaseName returns a mocked database name "postgres"

func (*MockInfo) HostPort

func (mi *MockInfo) HostPort() (string, string)

HostPort returns a mocked host name "testhost"

func (*MockInfo) NewConnection

func (mi *MockInfo) NewConnection(database string) (*PGSQLConnection, error)

NewConnection creates a new mock info connection from the mockinfo struct

type PGSQLConnection

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

PGSQLConnection represents a wrapper around a PostgreSQL connection

func CreateMockSQL

func CreateMockSQL(t *testing.T) (con *PGSQLConnection, mock sqlmock.Sqlmock)

CreateMockSQL creates a Test SQLConnection. Must Close con when done

func (PGSQLConnection) Close

func (p PGSQLConnection) Close()

Close closes the PosgreSQL connection. If an error occurs it is logged as a warning.

func (PGSQLConnection) HaveExtensionInSchema

func (p PGSQLConnection) HaveExtensionInSchema(extensionName, schemaName string) bool

HaveExtensionInSchema checks to see if the given Extension is installed on the current database in the given schema

func (PGSQLConnection) Query

func (p PGSQLConnection) Query(v interface{}, query string) error

Query runs a query and loads results into v

func (PGSQLConnection) Queryx

func (p PGSQLConnection) Queryx(query string) (*sqlx.Rows, error)

Queryx runs a query and returns a set of rows

Jump to

Keyboard shortcuts

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