gosql

package
v0.0.0-...-b425644 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IfNotExists

func IfNotExists(o *QueryOption)

func PublicTables

func PublicTables(o *tableOptions)

func PublicViews

func PublicViews(o *viewOptions)

func ScanMap

func ScanMap(rows *sql.Rows, m map[string]interface{}) error

func SelectInt

func SelectInt(db Dbi, q string, vars ...interface{}) (int, error)

func SelectInts

func SelectInts(db Dbi, q string, args ...interface{}) ([]int, error)

func SelectString

func SelectString(db Dbi, q string) (string, error)

func SelectStrings

func SelectStrings(db Dbi, q string, args ...interface{}) ([]string, error)

func SelectStruct

func SelectStruct(db Dbi, i interface{}, q string, params ...interface{}) error

func SelectStructs

func SelectStructs(db Dbi, q string, i interface{}, params ...interface{}) error

func UnmarshalRow

func UnmarshalRow(rows Rows, i interface{}) error

func UnmarshalRows

func UnmarshalRows(rows Rows, i interface{}) error

func WithName

func WithName(s string) tableOpt

Types

type Column

type Column struct {
	TableCatalog           string `sql:"table_catalog"`            // information_schema.sql_identifier
	TableSchema            string `sql:"table_schema"`             // information_schema.sql_identifier
	TableName              string `sql:"table_name"`               // information_schema.sql_identifier
	ColumnName             string `sql:"column_name"`              // information_schema.sql_identifier
	OrdinalPosition        int    `sql:"ordinal_position"`         // information_schema.cardinal_number
	ColumnDefault          string `sql:"column_default"`           // information_schema.character_data
	IsNullable             bool   `sql:"is_nullable"`              // information_schema.yes_or_no
	DataType               string `sql:"data_type"`                // information_schema.character_data
	CharacterMaximumLength int    `sql:"character_maximum_length"` // information_schema.cardinal_number
	CharacterOctetLength   int    `sql:"character_octet_length"`   // information_schema.cardinal_number
	NumericPrecision       int    `sql:"numeric_precision"`        // information_schema.cardinal_number
	NumericPrecisionRadix  int    `sql:"numeric_precision_radix"`  // information_schema.cardinal_number
	NumericScale           int    `sql:"numeric_scale"`            // information_schema.cardinal_number
	DatetimePrecision      int    `sql:"datetime_precision"`       // information_schema.cardinal_number
	IntervalType           string `sql:"interval_type"`            // information_schema.character_data
	IntervalPrecision      int    `sql:"interval_precision"`       // information_schema.cardinal_number
	CharacterSetCatalog    string `sql:"character_set_catalog"`    // information_schema.sql_identifier
	CharacterSetSchema     string `sql:"character_set_schema"`     // information_schema.sql_identifier
	CharacterSetName       string `sql:"character_set_name"`       // information_schema.sql_identifier
	CollationCatalog       string `sql:"collation_catalog"`        // information_schema.sql_identifier
	CollationSchema        string `sql:"collation_schema"`         // information_schema.sql_identifier
	CollationName          string `sql:"collation_name"`           // information_schema.sql_identifier
	DomainCatalog          string `sql:"domain_catalog"`           // information_schema.sql_identifier
	DomainSchema           string `sql:"domain_schema"`            // information_schema.sql_identifier
	DomainName             string `sql:"domain_name"`              // information_schema.sql_identifier
	UdtCatalog             string `sql:"udt_catalog"`              // information_schema.sql_identifier
	UdtSchema              string `sql:"udt_schema"`               // information_schema.sql_identifier
	UdtName                string `sql:"udt_name"`                 // information_schema.sql_identifier
	ScopeCatalog           string `sql:"scope_catalog"`            // information_schema.sql_identifier
	ScopeSchema            string `sql:"scope_schema"`             // information_schema.sql_identifier
	ScopeName              string `sql:"scope_name"`               // information_schema.sql_identifier
	MaximumCardinality     int    `sql:"maximum_cardinality"`      // information_schema.cardinal_number
	DtdIdentifier          string `sql:"dtd_identifier"`           // information_schema.sql_identifier
	IsSelfReferencing      bool   `sql:"is_self_referencing"`      // information_schema.yes_or_no
	IsIdentity             bool   `sql:"is_identity"`              // information_schema.yes_or_no
	IdentityGeneration     string `sql:"identity_generation"`      // information_schema.character_data
	IdentityStart          string `sql:"identity_start"`           // information_schema.character_data
	IdentityIncrement      string `sql:"identity_increment"`       // information_schema.character_data
	IdentityMaximum        string `sql:"identity_maximum"`         // information_schema.character_data
	IdentityMinimum        string `sql:"identity_minimum"`         // information_schema.character_data
	IdentityCycle          bool   `sql:"identity_cycle"`           // information_schema.yes_or_no
	IsGenerated            string `sql:"is_generated"`             // information_schema.character_data
	GenerationExpression   string `sql:"generation_expression"`    // information_schema.character_data
	IsUpdatable            bool   `sql:"is_updatable"`             // information_schema.yes_or_no
}

func Columns

func Columns(db Dbi) ([]*Column, error)

type ColumnValue

type ColumnValue struct {
	Name  string
	Value interface{}
}

type ColumnValues

type ColumnValues []*ColumnValue

func (ColumnValues) Len

func (list ColumnValues) Len() int

func (ColumnValues) Less

func (list ColumnValues) Less(a, b int) bool

func (ColumnValues) Names

func (list ColumnValues) Names() []string

func (ColumnValues) Swap

func (list ColumnValues) Swap(a, b int)

func (ColumnValues) Values

func (list ColumnValues) Values() []interface{}

type Dbi

type Dbi interface {
	QueryRow(query string, args ...interface{}) *sql.Row
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Prepare(query string) (*sql.Stmt, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

Dbi behaves like a db or transaction

type JsonType

type JsonType string

type Map

type Map map[string]interface{}

func (Map) Columns

func (m Map) Columns(names ...string) (ColumnValues, error)

func (Map) CreateTableStatement

func (m Map) CreateTableStatement(name string, opts ...func(*QueryOption)) (string, error)

func (Map) InsertStatement

func (m Map) InsertStatement(tableName string) (string, []interface{}, error)

type Migration

type Migration struct {
	Idx       int
	Statement string
	Logger    *log.Logger
	Executed  bool
}

func (*Migration) Execute

func (m *Migration) Execute(tx Dbi) (sql.Result, error)

type Migrator

type Migrator struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(migrations ...interface{}) *Migrator

func (*Migrator) Execute

func (list *Migrator) Execute(tx Dbi) error

type QueryOption

type QueryOption struct {
	IfNotExists bool
}

type Rows

type Rows interface {
	Columns() ([]string, error)
	Scan(...interface{}) error
	Next() bool
	Err() error
}

type Table

type Table struct {
	TableCatalog              string  `sql:"table_catalog"`
	TableSchema               string  `sql:"table_schema"`
	TableName                 string  `sql:"table_name"`
	TableType                 string  `sql:"table_type"`
	SelfReferencingColumnName *string `sql:"self_referencing_column_name"`
	ReferenceGeneration       *string `sql:"reference_generation"`
	UserDefinedTypeCatalog    *string `sql:"user_defined_type_catalog"`
	UserDefinedTypeSchema     *string `sql:"user_defined_type_schema"`
	UserDefinedTypeName       *string `sql:"user_defined_type_name"`
	IsInsertableInto          string  `sql:"is_insertable_into"`
	IsTyped                   string  `sql:"is_typed"`
	CommitAction              *string `sql:"commit_action"`
}

func Tables

func Tables(db Dbi, funcs ...tableOpt) ([]*Table, error)

type Valuer

type Valuer interface {
	Values() Map
}

type View

type View struct {
	TableCatalog            string `sql:"table_catalog"`              //              | information_schema.sql_identifier |
	TableSchema             string `sql:"table_schema"`               //               | information_schema.sql_identifier |
	TableName               string `sql:"table_name"`                 //                 | information_schema.sql_identifier |
	ViewDefinition          string `sql:"view_definition"`            //            | information_schema.character_data |
	CheckOption             string `sql:"check_option"`               //               | information_schema.character_data |
	IsUpdatable             string `sql:"is_updatable"`               //               | information_schema.yes_or_no      |
	IsInsertableInto        string `sql:"is_insertable_into"`         //         | information_schema.yes_or_no      |
	IsTriggerUpdatable      string `sql:"is_trigger_updatable"`       //       | information_schema.yes_or_no      |
	IsTriggerDeletable      string `sql:"is_trigger_deletable"`       //       | information_schema.yes_or_no      |
	IsTriggerInsertableInto string `sql:"is_trigger_insertable_into"` // | information_schema.yes_or_no      |
}

func Views

func Views(db Dbi, funcs ...viewOpt) ([]*View, error)

Jump to

Keyboard shortcuts

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