Documentation ¶
Index ¶
- func Insert(colNames []string, conf SQLConfig) string
- func Int64ToBool(c *Column) func(t interface{}) error
- func ReadSQL(rows *sql.Rows, conf SQLConfig) (map[string]types.DataSlice, []string, error)
- func StringToFloat(c *Column) func(t interface{}) error
- type ArgBuilder
- type CoerceFunc
- type Column
- type SQLConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Insert ¶
Insert generates a SQL insert statement for each colName. There are several variations of SQL that need to be produced for each driver. This has been tested with the following: PostgreSQL - github.com/lib/pq MySQL/MariaDB - github.com/go-sql-driver/mysql SQLite - github.com/mattn/go-sqlite3
"Parameter markers" are used to specify placeholders for values scanned by the implementing driver: PostgreSQL accepts "incrementing" markers e.g. $1..$2 While MySQL/MariaDB and SQLite accept ?..?.
func Int64ToBool ¶
Int64ToBool casts an int64 type into a boolean. This is useful for casting columns in SQLite which stores BOOL as INT types natively.
func ReadSQL ¶
ReadSQL returns a named map of types.DataSlice for consumption by the qframe.New constructor.
func StringToFloat ¶ added in v0.4.0
Types ¶
type ArgBuilder ¶
func NewArgBuilder ¶
func NewArgBuilder(col column.Column) (ArgBuilder, error)
type CoerceFunc ¶
CoerceFunc returns a function that does an explicit type cast from one input type and sets an internal column type.
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column implements the sql.Scanner interface and allows arbitrary data types to be loaded from any database/sql/driver into a QFrame.
type SQLConfig ¶
type SQLConfig struct { // Query is a Raw SQL statement which must return // appropriate types which can be inferred // and loaded into a new QFrame. Query string // Incrementing indicates the PostgreSQL variant // of parameter markers will be used, e.g. $1..$2. // The default style is ?..?. Incrementing bool // Table is the name of the table to be used // for generating an INSERT statement. Table string // EscapeChar is a rune which column and table // names will be escaped with. PostgreSQL and SQLite // both accept double quotes "" while MariaDB/MySQL // only accept backticks. EscapeChar rune // CoerceMap is a map of columns to perform explicit // type coercion on. CoerceMap map[string]CoerceFunc // Precision specifies how much precision float values // should have. 0 has no effect. Precision int }