Installation
Install a NetLifeGuru database driver and use the shared DB layer in your Go project.
The db package is a shared database layer.
It is not used as a standalone database driver. To create a real database connection, install one of the supported driver packages.
Installing a driver also installs the shared dependencies:
github.com/netlifeguru/db
github.com/netlifeguru/mapperChoose a Driver
Install the driver that matches your database.
MySQL
go get github.com/netlifeguru/db-mysqlUse this driver for MySQL and MySQL-compatible databases such as MariaDB.
import (
"github.com/netlifeguru/db"
"github.com/netlifeguru/db-mysql"
)PostgreSQL
go get github.com/netlifeguru/db-postgresUse this driver for PostgreSQL-compatible databases.
import (
"github.com/netlifeguru/db"
"github.com/netlifeguru/db-postgres"
)Scylla
go get github.com/netlifeguru/db-scyllaUse this driver for ScyllaDB and CQL-based workloads supported by the driver.
import (
"github.com/netlifeguru/db"
"github.com/netlifeguru/db-scylla"
)Install Multiple Drivers
You can install more than one driver in the same project.
go get github.com/netlifeguru/db-mysql
go get github.com/netlifeguru/db-postgres
go get github.com/netlifeguru/db-scyllaThis is useful when:
- one application can run with different database engines
- tests use a different database than production
- a migration tool needs to support multiple databases
- you are using dialect SQL files
Do Not Install DB Alone
You can technically install the shared package directly:
go get github.com/netlifeguru/dbHowever, this does not give you a working database connection by itself. The
dbpackage defines shared interfaces, helpers, query types, and result mapping behavior. A concrete driver is still required to connect to MySQL, PostgreSQL, or Scylla.
In most applications, install a driver instead:
go get github.com/netlifeguru/db-mysqlor:
go get github.com/netlifeguru/db-postgresor:
go get github.com/netlifeguru/db-scyllaRequirements
This package requires Go 1.22 or newer.
- Go:
1.22or newer - Connection driver: MySQL, PostgreSQL, or Scylla
- Shared database layer:
github.com/netlifeguru/db - Result mapper:
github.com/netlifeguru/mapper
Package Relationship
The packages are intended to be used together.
Application
↓
Driver package
↓
github.com/netlifeguru/db
↓
github.com/netlifeguru/mapperFor example, when you install:
go get github.com/netlifeguru/db-postgresyour project also receives the shared db and mapper packages.
Next Step
After installing a driver, continue with the driver-specific getting started guide:
- MySQL
- PostgreSQL
- Scylla