Documentation ¶
Index ¶
- Constants
- func CockroachURLFromEnv() string
- func HandleMigrationArgs(mig Migrate)
- func MustMigrateUp(mig Migrate)
- func MustOpenMigration(driverName, dsn, sourceURL string) *migrate.Migrate
- func MySQLURLFromEnv() string
- func OpenMigration(driverName, dsn, sourceURL string) (*migrate.Migrate, error)
- type Agent
- type Connector
- type DB
- func MustOpen(driverName, dsn string) *DB
- func MustOpenCockroachWithMigration(dsn, sourceURL string) (*DB, *migrate.Migrate)
- func MustOpenWithMigrations(driverName, dsn, sourceURL string) (*DB, *migrate.Migrate)
- func Open(driverName, dsn string) (*DB, error)
- func OpenCockroachWithMigration(dsn, sourceURL string) (*DB, *migrate.Migrate, error)
- func OpenWithMigrations(driverName, dsn, sourceURL string) (*DB, *migrate.Migrate, error)
- type Executor
- type Migrate
- type Operator
- type Pinger
- type Preparer
- type Querier
- type Transactor
Constants ¶
const (
// DefaultCockroachURL is the default url to a CockroachDB database.
DefaultCockroachURL = "tcp(127.0.0.1:26257)/defaultdb"
)
const (
// DefaultMySQLURL is the default url to a MYSQL database.
DefaultMySQLURL = "tcp(127.0.0.1:3306)/service"
)
Variables ¶
This section is empty.
Functions ¶
func CockroachURLFromEnv ¶ added in v0.3.0
func CockroachURLFromEnv() string
CockroachURLFromEnv tries to retrieve the cockroach url from the environment.
func HandleMigrationArgs ¶ added in v0.0.5
func HandleMigrationArgs(mig Migrate)
HandleMigrationArgs should be invoked to handle command line arguments for running migrations.
func MustMigrateUp ¶ added in v0.0.4
func MustMigrateUp(mig Migrate)
MustMigrateUp will attempt to migrate your database up.
func MustOpenMigration ¶ added in v0.3.0
func MustOpenMigration(driverName, dsn, sourceURL string) *migrate.Migrate
MustOpenMigration will open a migration instance with and crashes if unsuccessful.
func MySQLURLFromEnv ¶ added in v0.0.2
func MySQLURLFromEnv() string
MySQLURLFromEnv tries to retrieve the redis url from the environment.
func OpenMigration ¶ added in v0.3.0
OpenMigration will open a migration instance.
Types ¶
type Agent ¶ added in v0.0.9
type Agent interface { Preparer Transactor Executor Querier }
Agent defines a common set of methods for interacting with the data in an SQL database.
type Connector ¶
type Connector interface { Driver() driver.Driver SetMaxIdleConns(n int) SetMaxOpenConns(n int) SetConnMaxLifetime(d time.Duration) Conn(ctx context.Context) (*sql.Conn, error) Stats() sql.DBStats }
Connector defines a common set of methods for dealing with the connection to an SQL datbase.
type DB ¶
DB represents a wrapper for SQL DB providing extra methods.
func MustOpen ¶ added in v0.0.2
MustOpen will crash your program unless a database could be retrieved.
func MustOpenCockroachWithMigration ¶ added in v0.3.2
MustOpenCockroachWithMigration opens a cockroach database connection with an associated migration instance and craches if the connection cannot be obtained. This assumes you use a postgres driver like https://github.com/lib/pq to interact with your postgres database.
func MustOpenWithMigrations ¶ added in v0.0.3
MustOpenWithMigrations opens a database connection with an associated migration instance and crashes if unsuccessful.
func OpenCockroachWithMigration ¶ added in v0.3.0
OpenCockroachWithMigration opens a cockroach database connection with an associated migration instance. This assumes you use a postgres driver like https://github.com/lib/pq to interact with your postgres database.
func OpenWithMigrations ¶ added in v0.0.3
OpenWithMigrations opens a database connection with an associated migration instance.
type Executor ¶ added in v0.0.9
type Executor interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Exec(query string, args ...interface{}) (sql.Result, error) }
Executor defines a common set of methods for executing stored procedures, statements or queries.
type Operator ¶ added in v0.0.9
Operator defines a common set of methods for operating a connection with an SQL database.
type Preparer ¶
type Preparer interface { PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Prepare(query string) (*sql.Stmt, error) }
Preparer defines a common set of methods for preparing statements in an SQL database.
type Querier ¶
type Querier interface { QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row QueryRow(query string, args ...interface{}) *sql.Row }
Querier defines a common set of methods for querying an SQL database.