Relational Drivers

22 projects

Relational drivers connect Go to SQL databases, most of them by implementing the standard database/sql interfaces. That design means you open a connection pool with sql.Open, run queries with context, and can swap drivers or add tools such as sqlx, sqlc or an ORM on top. A few drivers also expose a native API with features database/sql cannot represent.

For MySQL and MariaDB, go-sql-driver/mysql is the standard choice. For PostgreSQL, jackc/pgx is the usual pick for new code: it offers a native interface with batching, COPY and LISTEN/NOTIFY, and a database/sql adapter; lib/pq is the older pure-Go database/sql driver. For SQLite there are three approaches: mattn/go-sqlite3 wraps the C library and needs cgo, modernc.org/sqlite is a cgo-free translation of SQLite to Go, and ncruces/go-sqlite3 runs SQLite compiled to WebAssembly, also without cgo. Microsoft maintains an official SQL Server driver, and godror connects to Oracle through ODPI-C. sqlhooks lets you wrap any driver with logging or tracing.

Choose pgx for PostgreSQL unless a library you depend on requires plain database/sql, and even then pgx's adapter works. For SQLite, decide on cgo first: a cgo-free driver keeps cross-compilation and static builds simple, while mattn/go-sqlite3 is the most battle-tested. Set pool limits such as SetMaxOpenConns explicitly instead of relying on defaults.

go-sql-driver/mysqlby go-sql-driver

MySQL driver for Go.

github.com/go-sql-driver/mysqlGo 1.25+ 2 dependenciesv1.10.1updated 3d ago

15.3k

pgxby jackc

PostgreSQL driver supporting features beyond those exposed by database/sql.

github.com/jackc/pgx/v5Go 1.25+ 6 dependenciesv5.11.0updated 3d ago

14.4k

pqby lib

Pure Go Postgres driver for database/sql.

github.com/lib/pqGo 1.23+ No dependencies v1.12.3updated 2mo ago

10k

go-sqlite3by mattn

SQLite3 driver for go that uses database/sql.

github.com/mattn/go-sqlite3Go 1.21+ No dependencies v1.14.52updated 1mo ago

9.3k

go-mssqldbby denisenkom

Microsoft MSSQL driver for Go.

github.com/denisenkom/go-mssqldbGo 1.13+ 5 dependenciesupdated 1y ago

1.9k

go-sqlite3by ncruces

This Go module is compatible with the database/sql driver. It allows embedding SQLite into your application, provides direct access to its C API, supports SQLite VFS, and also includes a GORM driver.

github.com/ncruces/go-sqlite3Go 1.26+ 12 dependenciesv0.36.0updated today

1.1k

sqlhooksby qustavo

Attach hooks to any database/sql driver.

github.com/qustavo/sqlhooks/v2Go 1.13+ 5 dependenciesv2.0.0updated 2y ago

664

go-oci8by mattn

Oracle driver for go that uses database/sql.

github.com/mattn/go-oci8Go 1.13+ No dependencies v0.1.1updated 3mo ago

634

godror

Oracle driver for Go, using the ODPI-C driver.

github.com/godror/godrorGo 1.25+ 8 dependenciesupdated 1mo ago

600

Sqinn-Goby cvilsmeier

SQLite with pure Go.

github.com/cvilsmeier/sqinn-go/v2Go 1.25+ No dependencies v2.1.9updated 18d ago

545

go-mssqldbby microsoft

Microsoft's official Go driver for SQL Server, Azure SQL, Azure Synapse, SQL database in Fabric, and Fabric Data Warehouse. Supports Azure AD, Always Encrypted, bulk operations.

github.com/microsoft/go-mssqldbGo 1.25+ 12 dependenciesv1.11.2updated 11d ago

414

KSQLby VinGarcia

A Simple and Powerful Golang SQL Library.

github.com/vingarcia/ksqlGo 1.18+ 1 dependencyv1.12.3updated 4d ago

361

surrealdb.goby surrealdb

SurrealDB Driver for Go.

github.com/surrealdb/surrealdb.goGo 1.23+ 6 dependenciesv1.8.0updated today

318

firebirdsqlby nakagami

Firebird RDBMS SQL driver for Go.

github.com/nakagami/firebirdsqlGo 1.22+ 5 dependenciesupdated 1d ago

270

go-rqliteby rqlite

A Go client for rqlite, providing easy-to-use abstractions for working with the rqlite API.

github.com/rqlite/gorqliteGo 1.17+ No dependencies updated 14d ago

187

ydb-go-sdkby ydb-platform

Native and database/sql driver YDB (Yandex Database).

github.com/ydb-platform/ydb-go-sdk/v3Go 1.24+ 13 dependenciesv3.156.0updated today

181

go-adodbby mattn

Microsoft ActiveX Object DataBase driver for go that uses database/sql.

github.com/mattn/go-adodbGo 1.14+ 2 dependenciesupdated 3mo ago

154

avaticaby apache

Apache Avatica/Phoenix SQL driver for database/sql.

github.com/apache/calcite-avatica-go/v5Go 1.25+ 4 dependenciesupdated 8d ago

126

gofreetdsby minus5

Microsoft MSSQL driver. Go wrapper over FreeTDS.

updated 5y ago

114

bgcby viant

Datastore Connectivity for BigQuery for go.

github.com/viant/bgcGo 1.21+ 7 dependenciesv0.9.0updated 2y ago

21

pigby alexeyco

Simple pgx wrapper to execute and scan query results easily.

archived

17

sqlite

Package sqlite is a sql/database driver using a CGo-free port of the C SQLite3 library.

pkg.go.dev

Esc

Type to search every entry. ↑↓ to move, Enter to open.