Documentation ¶
Index ¶
- func CreateTableIfNecessary(ctx context.Context, db Database, t Table) error
- func HasTable(ctx context.Context, db Database, table string) (bool, error)
- func HasTableWithSQLDB(ctx context.Context, db *sql.DB, table_name string) (bool, error)
- func LiveHardDieFast(ctx context.Context, db Database) error
- func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error
- func Schemes() []string
- type Database
- type DatabaseInitializationFunc
- type ResultRow
- type ResultSet
- type ResultSetFunc
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTableIfNecessary ¶
func HasTableWithSQLDB ¶
func RegisterDatabase ¶
func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error
RegisterDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Database` instances by the `NewDatabase` method.
Types ¶
type Database ¶
type Database interface { DSN(context.Context) string Conn(context.Context) (*sql.DB, error) Lock(context.Context) error Unlock(context.Context) error Close(context.Context) error SetLogger(context.Context, *log.Logger) error }
func NewDatabase ¶
NewDatabase returns a new `Database` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `DatabaseInitializationFunc` function used to instantiate the new `Database`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterDatabase` method.
type DatabaseInitializationFunc ¶
DatabaseInitializationFunc is a function defined by individual database package and used to create an instance of that database