postgresql

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 5 Imported by: 0

README

PostgreSQL

A simple library to work with PostgreSQL database.

Documentation

Index

Constants

View Source
const (
	DsnPrefix                    = "postgresql://"
	DsnUsernamePasswordDelimiter = ":"
	DsnUsernameHostDelimiter     = "@"
	DsnHostPortDelimiter         = ":"
	DsnHostDatabaseDelimiter     = "/"
	DsnParametersPrefix          = "?"
)

PostgreSQL constants.

View Source
const (
	SingleQuote      = `'`
	SingleQuoteTwice = SingleQuote + SingleQuote
	Underscore       = '_'
)

Symbols.

View Source
const (
	QueryFTableExists = `SELECT EXISTS
(
	SELECT 1
	FROM information_schema.tables
	WHERE
		table_schema = $1 AND
		table_name = $2
);`

	QueryFProcedureExists = `` /* 216-byte string literal not displayed */

)

SQL query templates.

View Source
const (
	// ErrFBadSymbol is an error message format for a bad symbol.
	ErrFBadSymbol = "bad symbol: '%v'"
)

Error message formats.

Variables

This section is empty.

Functions

func IdentifierIsGood

func IdentifierIsGood(
	identifierName string,
) (bool, error)

IdentifierIsGood checks whether the specified identifier is good.

func MakeDsn

func MakeDsn(
	host string,
	port string,
	database string,
	username string,
	password string,

	parameters string,
) (dsn string)

MakeDsn function returns a connection string for PostgreSQL database according to the documentation located at: "https://www.postgresql.org/docs/10/libpq-connect.html". Format reference: postgresql://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]

func ProcedureExists

func ProcedureExists(
	connection *sql.DB,
	schemaName string,
	procedureName string,
) (procedureExists bool, err error)

ProcedureExists function checks whether the specified procedure exists.

func ProcedureNameIsGood

func ProcedureNameIsGood(
	procedureName string,
) (bool, error)

ProcedureNameIsGood checks whether the specified procedure name is a good identifier.

func ScreenSingleQuotes

func ScreenSingleQuotes(
	src string,
) (dst string)

ScreenSingleQuotes function does the single quotes screening.

func TableExists

func TableExists(
	connection *sql.DB,
	schemaName string,
	tableName string,
) (result bool, err error)

TableExists function checks whether the specified table exists.

func TableNameIsGood

func TableNameIsGood(
	tableName string,
) (bool, error)

TableNameIsGood checks whether the specified table name is a good identifier.

Types

This section is empty.

Jump to

Keyboard shortcuts

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