package dbutil
import "github.com/hashicorp/vault/sdk/database/helper/dbutil"
Index ¶
- Variables
- func ParseURL(url string) (string, error)
- func QueryHelper(tpl string, data map[string]string) string
- func QuoteIdentifier(name string) string
- func StatementCompatibilityHelper(statements dbplugin.Statements) dbplugin.Statements
- func Unimplemented() error
Variables ¶
var ( ErrEmptyCreationStatement = errors.New("empty creation statements") ErrEmptyRotationStatement = errors.New("empty rotation statements") )
Functions ¶
func ParseURL ¶
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 ¶
Query templates a query for us.
func QuoteIdentifier ¶
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 ¶
func Unimplemented() error
Unimplemented returns a gRPC error with the Unimplemented code
Source Files ¶
dbutil.go parseurl.go quoteidentifier.go
- Version
- v0.18.0 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 1 month ago –
Tools for package owners.