Documentation ¶
Overview ¶
Package sql is an extension to standard library "database/sql.DB" that provide common functionality across DBMS.
Index ¶
Constants ¶
const ( DriverNameMysql = "mysql" DriverNamePostgres = "postgres" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client provide a wrapper for generic database instance.
func (*Client) FetchTableNames ¶
FetchTableNames return the table names in current database schema sorted in ascending order.
func (*Client) Migrate ¶ added in v0.16.0
func (cl *Client) Migrate(fs http.FileSystem) (err error)
Migrate the database using list of SQL files inside a directory. Each SQL file in directory will be executed in alphabetical order based on the last state.
The state of migration will be saved in table "_migration" including the SQL file name that has been executed and the timestamp.
func (*Client) TruncateTable ¶
TruncateTable truncate all data on table `tableName`.
type Row ¶
type Row map[string]interface{}
Row represent a single row in table.
func (Row) ExtractSQLFields ¶
ExtractSQLFields extract the column's name, column place holder (default is "?"), and column values; as slices.
type Session ¶
type Session interface { Exec(query string, args ...interface{}) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Session is an interface that represent both sql.DB and sql.Tx.