Documentation ¶
Overview ¶
Package sql is an extension to standard library "database/sql.DB" that provide common functionality across DBMS.
Index ¶
Constants ¶
View Source
const ( DriverNameMysql = "mysql" DriverNamePostgres = "postgres" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { DB *sql.DB DriverName string TableNames []string // List of tables in database. }
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) 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.
Click to show internal directories.
Click to hide internal directories.