Documentation
¶
Overview ¶
Package sqldb is a general SQL DB backend implementation that takes an stdlib sql.DB connection and creates tables and writes results to it. It has explicit support for MySQL and PostGres for handling differences in SQL dialects, but should ideally work with any standard SQL backend.
Index ¶
- type Opt
- type SQLDBResultSet
- func (w *SQLDBResultSet) Close() error
- func (w *SQLDBResultSet) Flush() error
- func (w *SQLDBResultSet) IsColTypesRegistered() bool
- func (w *SQLDBResultSet) RegisterColTypes(cols []string, colTypes []*sql.ColumnType) error
- func (w *SQLDBResultSet) WriteCols(cols []string) error
- func (w *SQLDBResultSet) WriteRow(row []interface{}) error
- type SqlDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SQLDBResultSet ¶
type SQLDBResultSet struct {
// contains filtered or unexported fields
}
SQLDBResultSet represents a writer that saves results to a sqlDB backend.
func (*SQLDBResultSet) Close ¶
func (w *SQLDBResultSet) Close() error
Close closes the active sqlDB connection.
func (*SQLDBResultSet) Flush ¶
func (w *SQLDBResultSet) Flush() error
Flush flushes the rows written into the sqlDB pipe.
func (*SQLDBResultSet) IsColTypesRegistered ¶
func (w *SQLDBResultSet) IsColTypesRegistered() bool
IsColTypesRegistered checks whether the column types for a particular taskName's structure is registered in the backend.
func (*SQLDBResultSet) RegisterColTypes ¶
func (w *SQLDBResultSet) RegisterColTypes(cols []string, colTypes []*sql.ColumnType) error
RegisterColTypes registers the column types of a particular taskName's result set. Internally, it translates sql types into the simpler sqlDB (SQLite 3) types, creates a CREATE TABLE() schema for the results table with the structure of the particular taskName, and caches it be used for every subsequent result db creation and population. This should only be called once for each kind of taskName.
func (*SQLDBResultSet) WriteCols ¶
func (w *SQLDBResultSet) WriteCols(cols []string) error
WriteCols writes the column (headers) of a result set to the backend. Internally, it creates a sqlDB database and creates a results table based on the schema RegisterColTypes() would've created and cached. This should only be called once on a ResultWriter instance.
func (*SQLDBResultSet) WriteRow ¶
func (w *SQLDBResultSet) WriteRow(row []interface{}) error
WriteRow writes an individual row from a result set to the backend. Internally, it INSERT()s the given row into the sqlDB results table.
type SqlDB ¶
type SqlDB struct {
// contains filtered or unexported fields
}
SqlDB represents the SqlDB backend.
func NewSQLBackend ¶
NewSQLBackend returns a new sqlDB result backend instance.
func (*SqlDB) NewResultSet ¶
NewResultSet returns a new instance of an sqlDB result writer. A new instance should be acquired for every individual job result to be written to the backend and then thrown away.