vormia-go-driver-mysql
Pure-Go MySQL driver for Vormia Go — thin database/sql wrapper over go-sql-driver/mysql that satisfies the shared Database contract.
Install
go get github.com/vormialabs/vormia-go-driver-mysql@v1.1.0
Usage
import mysql "github.com/vormialabs/vormia-go-driver-mysql"
db, err := mysql.Open(mysql.Config{
Host: "localhost",
Port: 3306,
User: "root",
Password: "secret",
Database: "myapp",
})
if err != nil {
log.Fatal(err)
}
defer db.Close()
// MySQL uses ? placeholders natively; Rebind is the identity function
// and exists only to keep queries portable across drivers.
query := db.Rebind("SELECT * FROM users WHERE id = ?")
rows, err := db.QueryContext(ctx, query, userID)
parseTime=true and loc=UTC are set by default, so DATETIME/TIMESTAMP columns scan into time.Time instead of []byte.
Config
| Field |
Default |
Description |
Host |
localhost |
MySQL host |
Port |
3306 |
MySQL port |
Params |
— |
Extra DSN parameters (e.g. "charset": "utf8mb4") |
MaxOpenConns |
0 (unlimited) |
Set deliberately in production (e.g. 10–25) |
MaxIdleConns |
0 |
Idle connections kept in the pool |
ConnMaxLifetime |
0 |
Max lifetime of a connection |
Testing
Unit tests (TestRebind, contract check) run without a database:
go test ./...
Integration tests require a running MySQL. Set MYSQL_TEST_HOST to enable them:
docker run --name vormia-mysql \
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_DATABASE=testdb \
-p 3306:3306 -d mysql:8
# MySQL takes a few seconds to accept connections on first boot.
export MYSQL_TEST_HOST=127.0.0.1
export MYSQL_TEST_PASSWORD=root
go test -v ./...
| Env var |
Default |
MYSQL_TEST_HOST |
(required to run integration tests) |
MYSQL_TEST_PORT |
3306 |
MYSQL_TEST_USER |
root |
MYSQL_TEST_PASSWORD |
root |
MYSQL_TEST_DB |
testdb |
Release Notes
v1.1.0
- Confirmed ready for framework
db.Wipe / seed.Run (db:wipe / db:seed) using only the existing Database contract (QueryContext, ExecContext, BeginTx).
- MySQL wipe pattern verified: catalog via
information_schema, SET FOREIGN_KEY_CHECKS=0/1, and non-transactional DROP TABLE as separate ExecContext calls (no multiStatements DSN change).
- No public API or behavior changes in this driver.
v1.0.0
- Initial release: thin
database/sql wrapper over go-sql-driver/mysql with shared Database contract, identity Rebind, and default parseTime=true / loc=UTC.
License
MIT