sql

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sql provides basic functionality for accessing a PostgreSQL database.

Index

Constants

This section is empty.

Variables

View Source
var NoData = sql.ErrNoRows

Functions

func BuildWhere added in v0.1.11

func BuildWhere(cols []string) string

func Exec

func Exec(ctx *b.Context, qu string, args ...interface{}) error

Exec executes a SQL update, insert, or delete statement.

func ExecDB added in v0.1.12

func ExecDB(ctx *b.Context, db *Storage, qu string, args ...interface{}) error

func ExecDBN added in v0.1.15

func ExecDBN(ctx *b.Context, db *Storage, qu string,
	args ...interface{}) (int64, error)

func ExecN added in v0.1.15

func ExecN(ctx *b.Context, qu string, args ...interface{}) (int64, error)

ExecN executes a SQL update, insert, or delete statement, returning the number of affected rows together with the error returned by the execution.

func Query

func Query(ctx *b.Context, process func(*Rows) error, qu string,
	args ...interface{}) error

Function Query executes a SQL query and calls the process closure using the Rows object returned by the query.

func QueryDB added in v0.1.12

func QueryDB(ctx *b.Context, db *Storage, process func(*Rows) error, qu string,
	args ...interface{}) error

func QueryNumber added in v0.1.11

func QueryNumber(ctx *b.Context, qu string, args ...interface{}) (uint64, error)

Function QueryNumber executes the SQL query given and returns a scalar numeric value.

func QueryNumberDB added in v0.1.12

func QueryNumberDB(ctx *b.Context, db *Storage, qu string,
	args ...interface{}) (uint64, error)

func QueryRow added in v0.1.11

func QueryRow(ctx *b.Context, process func(*Row) error, qu string,
	args ...interface{}) error

Function QueryRow excecutes a SQL query that returns exactly one Row and calls the process closure using the Row object returned by the query.

func QueryRowDB added in v0.1.12

func QueryRowDB(ctx *b.Context, db *Storage, process func(*Row) error, qu string,
	args ...interface{}) error

func QueryRows added in v0.1.11

func QueryRows(ctx *b.Context, qu string, args ...interface{}) (*sql.Rows, error)

Funtion QueryRows executes a SQL query and returns the sql.Rows object. It is the responsibility of the caller to iterate over the Rows object returned and scan the individual rows.

func QueryRowsDB added in v0.1.12

func QueryRowsDB(ctx *b.Context, db *Storage, qu string,
	args ...interface{}) (*sql.Rows, error)

func QueryString added in v0.1.11

func QueryString(ctx *b.Context, qu string, args ...interface{}) (string, error)

Function QueryString executes the SQL query given and returns a scalar string value.

func QueryStringDB added in v0.1.12

func QueryStringDB(ctx *b.Context, db *Storage, qu string,
	args ...interface{}) (string, error)

func Start

func Start(ctx *b.Context)

Start is a generic actor startup handler that connects to a database and stores the db connection via a Storage object in the context.

func StartDB added in v0.1.12

func StartDB(ctx *b.Context) *sql.DB

Types

type NullBool added in v0.1.15

type NullBool = sql.NullBool

type NullInt64 added in v0.1.11

type NullInt64 = sql.NullInt64

type NullString added in v0.1.11

type NullString = sql.NullString

type Row added in v0.1.11

type Row = sql.Row

type Rows

type Rows = sql.Rows

type Storage

type Storage struct {
	*sql.DB
	b.DefaultState
}

type Storage provides database access. Implements interface b.ContextState.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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