dbsgomysql

An open-source library giving Go projects one well-tested answer to questions about MySQL schema. 
 *"Does this table have a single, composite, or no primary key?"*, *"which foreign keys point into this set of tables?"*, *"does the connected account hold DELETE on these tables?"* β€” answered once, answered correctly.

View on GitHub β†’
$ go get github.com/dbsmedya/dbsgomysql
βœ“ go 1.24+ Β· zero dependencies
$ go test ./... -tags=integration
βœ“ verified on MySQL 8.0 Β· 8.4 Β· 9.7

Facts, not policy.

The library answers factual questions and reports findings with a documented rationale. It never decides whether a finding matters β€” mapping a finding to fatal, warning, or ignore is your policy. That separation is why a check survives one consumer outgrowing it: the question stays answerable for everyone else.

Schema facts

  • Primary key shape: single, composite, or absent
  • Foreign keys pointing into a given set of tables
  • Column types and `information_schema` detail
  • Per-table privileges held by the connected account

Validation checks

  • 15 pure catalog checks with documented rationale
  • Table specification and diff facts
  • 5 pure catalog checks over replication
  • Identifier validation and quoting (`pkg/sqlutil`)

Replication facts

  • Replica channel status and registered replicas
  • Binary log enablement and coordinates
  • GTID state and replication configuration
  • Tested against a live source-replica topology

Design principles

The four rules that keep the library durable.

Zero dependencies

Library code imports the Go standard library only. It adds nothing to your dependency tree.

Driver-agnostic

You supply the connection β€” a *sql.DB, *sql.Conn, or *sql.Tx. The library never opens, configures, or closes one, and never imports a driver.

Never panics, never logs

It returns data and errors. You decide what reaches a terminal.

Context-first

Every call that touches the database takes a context.Context as its first argument.

It tracks MySQL version differences so you don’t have to

information_schema behaviour changes quietly between MySQL versions. dbsgomysql tracks those differences, tested against 8.0, 8.4 and 9.7 β€” with 26.x watched β€” so consumers never have to rediscover the same traps.

The library is used in production by GoArchive , which relies on it for schema, foreign-key and privilege checks before it moves any related data.

Talk to the team that builds it

The MySQL expertise behind these tools is also available as consulting and support, in English as well as Turkish.

Get in touch