postgresql

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DsnPrefix                    = "postgresql://"
	DsnUsernamePasswordDelimiter = ":"
	DsnUsernameHostDelimiter     = "@"
	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/15/libpq-connect.html Format reference: postgresql://[user[:password]@][host][: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