Documentation
¶
Index ¶
- Variables
- func DoubleQuote(value string) string
- func IsSupportedType(value string) bool
- func QuoteIdentifier(value string) string
- func QuoteIdentifiers(values ...string) string
- func RowMap(row []Value) map[string]Value
- func RowString(row []Value) string
- func SupportedTypeForType(v interface{}) string
- func SupportedTypes() []string
- func SupportedTypesForValue(value string) []string
- func ToSupportedType(value, decltype string, notnull bool, timezone *time.Location) (interface{}, error)
- type Class
- type Column
- type Connection
- type CreateIndex
- type CreateTable
- type Delete
- type Drop
- type Expression
- type Flag
- type InsertOrReplace
- type Language
- type Object
- type Objects
- type Result
- type Rows
- type Select
- type Source
- type Statement
- type StructClass
- type Transaction
- type Update
- type Value
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DoubleQuote ¶
DoubleQuote puts double quotes around a string and escapes existing double quotes
func IsSupportedType ¶
IsSupportedType returns true if the value provided is a reserved type
func QuoteIdentifier ¶
QuoteIdentifier returns a safe version of an identifier
func QuoteIdentifiers ¶ added in v1.0.3
QuoteIdentifiers returns a safe version of a list of identifiers, separated by commas
func SupportedTypeForType ¶ added in v1.0.3
func SupportedTypeForType(v interface{}) string
func SupportedTypes ¶ added in v1.0.2
func SupportedTypes() []string
SupportedTypes returns all supported types
func SupportedTypesForValue ¶ added in v1.0.2
SupportedTypesForValue returns most likely supported types for a value, in order. It will always return at least one type, with the most likely type as the zero'th element
Types ¶
type Column ¶
type Column interface {
Name() string
DeclType() string
Nullable() bool
PrimaryKey() bool
Index() int
Query() string
}
Column represents the specification for a table column
type Connection ¶
type Connection interface {
gopi.Driver
Transaction
// Perform operations within a transaction, rollback on error
Txn(func(Transaction) error) error
// Return sqlite information
Version() string
Schemas() []string
Tables() []string
TablesEx(schema string, include_temporary bool) []string
ColumnsForTable(name, schema string) ([]Column, error)
// Attach and detach other databases, schema cannot be 'main' or 'temp'
Attach(schema, dsn string) error
Detach(schema string) error
}
Connection to a database
type CreateIndex ¶ added in v1.0.6
type CreateIndex interface {
Statement
Schema(string) CreateIndex
Unique() CreateIndex
IfNotExists() CreateIndex
}
CreateIndex statement
type CreateTable ¶
type CreateTable interface {
Statement
Schema(string) CreateTable
IfNotExists() CreateTable
Temporary() CreateTable
WithoutRowID() CreateTable
Unique(...string) CreateTable
}
CreateTable statement
type Delete ¶ added in v1.0.6
type Delete interface {
Statement
Schema(string) Delete
Where(Expression) Delete
}
Delete statement
type Expression ¶ added in v1.0.6
type Expression interface {
Query() string
}
Expression represents an expression used in Select
type InsertOrReplace ¶ added in v1.0.2
type InsertOrReplace interface {
Statement
Schema(string) InsertOrReplace
DefaultValues() InsertOrReplace
}
InsertOrReplace represents an insert or replace
type Language ¶ added in v1.0.5
type Language interface {
gopi.Driver
// Create
NewCreateTable(string, ...Column) CreateTable
NewCreateIndex(string, string, ...string) CreateIndex
// Drop
DropTable(string) Drop
DropIndex(string) Drop
DropTrigger(string) Drop
DropView(string) Drop
// Insert, replace and update
Insert(string, ...string) InsertOrReplace
Replace(string, ...string) InsertOrReplace
NewDelete(string) Delete
NewUpdate(string, ...string) Update
// Select
NewSelect(Source) Select
// Return named data source
NewSource(name string) Source
// Build expressions
Null() Expression
Arg() Expression
Value(interface{}) Expression
Equals(string, Expression) Expression
NotEquals(string, Expression) Expression
And(...Expression) Expression
Or(...Expression) Expression
}
Language component to build statements
type Objects ¶ added in v1.0.4
type Objects interface {
gopi.Driver
// RegisterStruct registers a struct against a database table
RegisterStruct(interface{}) (StructClass, error)
// ReflectStruct returns SQL table columns from a struct
ReflectStruct(v interface{}) ([]Column, error)
// Insert, replace and update structs, rollback on error
// and return number of affected rows
Write(Flag, ...interface{}) (uint64, error)
// Delete structs or by rowid, rollback on error
// and return number of affected rows
Delete(...interface{}) (uint64, error)
}
type Rows ¶
type Rows interface {
// Return column names
Columns() []Column
// Return next row of values, or nil if no more rows
Next() []Value
}
Rows increments over returned rows from a query
type Select ¶
type Select interface {
Statement
Distinct() Select
Where(...Expression) Select
LimitOffset(uint, uint) Select
}
Select statement
type Source ¶ added in v1.0.3
Source represents a simple table source (schema, name and table alias)
type StructClass ¶ added in v1.0.4
type StructClass interface {
Class
}
type Transaction ¶ added in v1.0.5
type Transaction interface {
// Return statement anc column
NewStatement(string) Statement
NewColumn(name, decltype string, nullable, primary bool) Column
NewColumnWithIndex(name, decltype string, nullable, primary bool, index int) Column
// Execute statement (without returning the rows)
Do(Statement, ...interface{}) (Result, error)
DoOnce(string, ...interface{}) (Result, error)
// Query to return the rows
Query(Statement, ...interface{}) (Rows, error)
QueryOnce(string, ...interface{}) (Rows, error)
}
Transaction that can be committed/rolled back
type Update ¶ added in v1.0.6
type Update interface {
Statement
Schema(string) Update
Where(Expression) Update
}
Update represents an update
type Value ¶
type Value interface {
String() string // Return value as string
Int() int64 // Return value as int
Bool() bool // Return value as bool
Float() float64 // Return value as float
Timestamp() time.Time // Return value as timestamp
Bytes() []byte // Return value as blob
// Return the column associated with the value
Column() Column
// Return true if value is NULL
IsNull() bool
}
Value represents a typed value in a table