Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ErrDuplicateEntry indicates a 'unique' constraint violation on insert. // Message: Duplicate entry '%s' for key %d ErrDuplicateEntry = 1062 // ErrNoResults indicates the MySQL query returned no rows. // Message: Query was empty ErrNoResults = 1065 )
The following covers a small set of the MySQL numerical error codes. See https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html for more information.
Variables ¶
This section is empty.
Functions ¶
func GetTxOrFailTesting ¶
GetTxOrFailTesting creates and returns a database transaction, or will end the unit test by calling t.Fatal()
func MustConnect ¶
MustConnect connects and returns a database connection, or calls os.Exit(1).
This sets several default parameters for the MySQL database:
- collation: Sets the charset, but avoids the additional queries of charset
- parseTime: changes the output type of DATE and DATETIME values to time.Time instead of []byte / string
- interpolateParams: Reduces the number of round trips required to interpolate placeholders (i.e. ?)
func SetupBenchmarkDatabase ¶ added in v0.3.0
SetupBenchmarkDatabase creates and returns an empty database, using the the database name foo_test, where 'foo' is the name in the config.
Types ¶
type Config ¶
type Config struct { // Username: MySQL user to login as. Username string // Password: The MySQL user's password. Password string // Address: Either 'localhost' or an IP such as '192.168.1.100' Address string // DBName: The name of the MySQL database to use. DBName string }
Config holds the database configuration, required for connecting to and using the database.
Click to show internal directories.
Click to hide internal directories.