dbutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MPL-2.0 Imports: 9 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyCreationStatement = errors.New("empty creation statements")
	ErrEmptyRotationStatement = errors.New("empty rotation statements")
)

Functions

func ParseURL added in v0.5.0

func ParseURL(url string) (string, error)

ParseURL no longer needs to be used by clients of this library since supplying a URL as a connection string to sql.Open() is now supported:

sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full")

It remains exported here for backwards-compatibility.

ParseURL converts a url to a connection string for driver.Open. Example:

"postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full"

converts to:

"user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full"

A minimal example:

"postgres://"

This will be blank, causing driver.Open to use all of the defaults

func QueryHelper

func QueryHelper(tpl string, data map[string]string) string

Query templates a query for us.

func QuoteIdentifier added in v0.5.0

func QuoteIdentifier(name string) string

QuoteIdentifier quotes an "identifier" (e.g. a table or a column name) to be used as part of an SQL statement. For example:

tblname := "my_table"
data := "my_data"
quoted := pq.QuoteIdentifier(tblname)
err := db.Exec(fmt.Sprintf("INSERT INTO %s VALUES ($1)", quoted), data)

Any double quotes in name will be escaped. The quoted identifier will be case sensitive when used in a query. If the input string contains a zero byte, the result will be truncated immediately before it.

func StatementCompatibilityHelper

func StatementCompatibilityHelper(statements dbplugin.Statements) dbplugin.Statements

StatementCompatibilityHelper will populate the statements fields to support compatibility

func Unimplemented added in v0.1.12

func Unimplemented() error

Unimplemented returns a gRPC error with the Unimplemented code

Types

This section is empty.

Jump to

Keyboard shortcuts

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