Documentation ¶
Index ¶
- Constants
- func ExecuteQuery(ctx context.Context, client DbClient, queryString string, args ...any) (*queryresult.ResultStreamer, error)
- func MaxDbConnections() int
- func PgEscapeName(name string) string
- func PgEscapeSearchPath(searchPath []string) []string
- func PgEscapeString(str string) string
- type DbClient
- func (c *DbClient) Close(context.Context) error
- func (c *DbClient) Execute(ctx context.Context, query string, args ...any) (*localqueryresult.Result, error)
- func (c *DbClient) ExecuteSync(ctx context.Context, query string, args ...any) (*localqueryresult.SyncQueryResult, error)
- func (c *DbClient) GetConnectionString() string
- func (c *DbClient) StartQuery(ctx context.Context, dbConn *sql.Conn, query string, args ...any) (rows *sql.Rows, err error)
- type PgxConnector
Constants ¶
const ( MaxConnLifeTime = 10 * time.Minute MaxConnIdleTime = 1 * time.Minute )
const ( DriverPostgres = "pgx" DriverMySQL = "mysql" DriverDuckDB = "duckdb" DriverSQLite = "sqlite3" DriverUnknown = "_unknown_" )
Variables ¶
This section is empty.
Functions ¶
func ExecuteQuery ¶
func ExecuteQuery(ctx context.Context, client DbClient, queryString string, args ...any) (*queryresult.ResultStreamer, error)
ExecuteQuery executes a single query. If shutdownAfterCompletion is true, shutdown the client after completion
func MaxDbConnections ¶
func MaxDbConnections() int
func PgEscapeName ¶
PgEscapeName escapes strings which will be usaed for Podsdtgres object identifiers (table names, column names, schema names)
func PgEscapeSearchPath ¶
PgEscapeSearchPath applies postgres escaping to search path and remove whitespace
func PgEscapeString ¶
PgEscapeString escapes strings which are to be inserted use a custom escape tag to avoid chance of clash with the escaped text https://medium.com/@lnishada/postgres-dollar-quoting-6d23e4f186ec
Types ¶
type DbClient ¶
type DbClient struct { // TODO KAI new hook <TIMING> BeforeExecuteHook func(context.Context, *sql.Conn) error // contains filtered or unexported fields }
DbClient wraps over `sql.DB` and gives an interface to the database
func NewDbClient ¶
func (*DbClient) Execute ¶
func (c *DbClient) Execute(ctx context.Context, query string, args ...any) (*localqueryresult.Result, error)
execute the query in the given Context NOTE: The returned Result MUST be fully read - otherwise the connection will block and will prevent further communication
func (*DbClient) ExecuteSync ¶
func (c *DbClient) ExecuteSync(ctx context.Context, query string, args ...any) (*localqueryresult.SyncQueryResult, error)
execute a query against this client and wait for the result
func (*DbClient) GetConnectionString ¶
func (*DbClient) StartQuery ¶
func (c *DbClient) StartQuery(ctx context.Context, dbConn *sql.Conn, query string, args ...any) (rows *sql.Rows, err error)
StartQuery runs query in a goroutine, so we can check for cancellation in case the client becomes unresponsive and does not respect context cancellation