talira

Go-MySQL-Driver

A pure Go MySQL driver for the database/sql package

open sourceMPL-2.0free

Go-MySQL-Driver is the MySQL driver most Go programs use with the standard library's database/sql package. It is written in pure Go with no C bindings, connects over TCP, Unix sockets or custom dialers, handles broken connections, and supports queries over 16 MB, LOAD DATA LOCAL INFILE with an allowlist, optional time.Time parsing and placeholder interpolation, and zlib or zstd compression. Its maintainers support MySQL 8.0+ and MariaDB Server 10.11+ on the three latest Go releases. It is MPL-2.0.

Problems it solves

  • connect my Go service to a MySQL database
  • use database/sql with MariaDB from Go without cgo
  • parse MySQL DATETIME columns into time.Time in Go
  • configure TLS and timeouts for a MySQL connection string in Go
  • bulk load a CSV into MySQL from a Go program

Features

  • pure Go, no C bindings or cgo
  • plugs into Go's database/sql with its connection pooling
  • TCP, IPv6, Unix domain socket and custom dial connections
  • automatic handling of broken connections
  • queries larger than 16 MB and LONG DATA in prepared statements
  • LOAD DATA LOCAL INFILE with file allowlisting and io.Reader support
  • optional time.Time parsing and client-side placeholder interpolation
  • zlib and optional zstd compression

Alternatives

The same job

These do what Go-MySQL-Driver does.

  1. go-sqlite3 A SQLite3 driver for Go using database/sql

Compare Go-MySQL-Driver with the top 3