database

package
v1.0.12-rc-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package database provides database connection management and query session creation across supported SQL backends.

It opens and configures *sql.DB connection pools from a DataSourceName, resolves the configured database type to a driver, and builds upper/db query sessions via the mysqldriver and postgresdriver subpackages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(dbType string, config *DataSourceName) (*sql.DB, error)

Get a connection to a database and return connection pool

Types

type DataSourceName

type DataSourceName struct {
	Host         string
	Port         string
	User         string
	Password     string
	DatabaseName string
	SslMode      string
}

type Database

type Database struct {
	DataType string
	Pool     *sql.DB
}

func (*Database) NewSession

func (a *Database) NewSession() db.Session

NewSession creates a new sqlbuilder.Session instance based on the configured database type. Returns nil if no database is configured.

Directories

Path Synopsis
Package migrations provides database migration utilities built on top of golang-migrate.
Package migrations provides database migration utilities built on top of golang-migrate.
Package mysqldriver provides MySQL-specific helpers for the database layer.
Package mysqldriver provides MySQL-specific helpers for the database layer.
Package postgresdriver provides PostgreSQL-specific helpers for the database layer.
Package postgresdriver provides PostgreSQL-specific helpers for the database layer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL