db

package
v0.0.0-...-7b00875 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBClient

type DBClient struct {
	// contains filtered or unexported fields
}

func CreateDBClient

func CreateDBClient(connManager *conn.ConnectionManager) (*DBClient, error)

Instantiate a DBClient from a DSN

func (*DBClient) Destroy

func (db *DBClient) Destroy()

Cleanup database resources Call before this struct drops out of scope

func (*DBClient) Query

func (db *DBClient) Query(statement string) (results *QueryResult, err error)

Run a query and store the output in a displayable format NOTE: results and error may both be nil if a query is succesful yet doesn't return any rows

type NullString

type NullString struct {
	sql.NullString
}

func (*NullString) MarshalJSON

func (nullString *NullString) MarshalJSON() ([]byte, error)

func (*NullString) ToString

func (nullString *NullString) ToString() string

type QueryResult

type QueryResult struct {
	// Each row maps column -> value
	// Why NullString for values?
	// Making a more generic type here to store any SQL value results in some messy reflection code
	// For our purposes, we can store all data types as either string or null, since our main
	// intention is to render them as string
	Rows []map[string]*NullString
	// Column names, order preserved with how they were selected
	Columns []string
}

func (*QueryResult) ToCSV

func (queryResult *QueryResult) ToCSV() (res []byte)

func (*QueryResult) ToJSON

func (queryResult *QueryResult) ToJSON() (res []byte)

type StatementWithParams

type StatementWithParams struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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