sqldb

package
v0.0.0-...-9e5d004 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(cfg config.SqlDB) (*sql.DB, error)

OpenDB takes a config.SqlDB configuration, attempts to open a connection to it, sets some important properties and then tests the connection before returning a pointer to the connection and an error.

Types

type ErrUniqueConstraintViolation

type ErrUniqueConstraintViolation struct {
	Columns []string
	Message string
	Table   string
}

ErrUniqueConstraintViolation is a database-agnostic error for unique constraint violations. Columns is a slice of strings in case the constraints spans multiple columns.

func NewUniqueConstraintErr

func NewUniqueConstraintErr(table, column string, columns ...string) *ErrUniqueConstraintViolation

NewUniqueConstraintErr returns a new ErrUniqueConstraintViolation with the fields appropriately set. At least one column must be provided and more can be provided in the case of composite unique constraints.

func (ErrUniqueConstraintViolation) Error

Error implements the Error() interface.

Jump to

Keyboard shortcuts

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