> A warrior's deeds are committed to stone so that what they built survives the builder.
`code.nochebuena.dev/einherjar/db-mysql` is the MySQL/MariaDB database component of the Einherjar framework. It wraps `database/sql` with `go-sql-driver/mysql` behind a lifecycle-aware `Component`, exposes a uniform `Executor` interface for queries and transactions, and provides a `UnitOfWork` that injects the active transaction into context — so repositories never need to know whether they are inside a transaction or not.
`UnitOfWork` wraps the transaction in context so every call to `GetExecutor` inside `uow.Do` automatically returns the active transaction. Repositories require no changes.
```go
uow:=dbmysql.NewUnitOfWork(logger,db)
err:=uow.Do(ctx,func(ctxcontext.Context)error{
_,err:=db.GetExecutor(ctx).ExecContext(ctx,"INSERT INTO orders (...) VALUES (...)",...)
returnerr
})
```
If the function returns an error, the transaction is rolled back. If it returns nil, the transaction is committed.
| `EINHERJAR_MYSQL_MAX_CONN_LIFETIME` | No | `1h` | Maximum connection lifetime |
| `EINHERJAR_MYSQL_MAX_CONN_IDLE_TIME` | No | `30m` | Maximum idle time before connection is closed |
| `EINHERJAR_MYSQL_CHARSET` | No | `utf8mb4` | Connection charset |
| `EINHERJAR_MYSQL_LOC` | No | `UTC` | Timezone location |
| `EINHERJAR_MYSQL_PARSE_TIME` | No | `true` | Parse `DATE`/`DATETIME` as `time.Time` |
> **Note:** Set collation at the schema level (DDL), not in the DSN. MariaDB 11.4+ collation names exceed the 1-byte handshake limit in `go-sql-driver`.