database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists added in v1.0.0

func Exists(dbPath string) (bool, error)

Exists checks if the database folder exists and is not empty.

Types

type Engine

type Engine string
const (
	EngineUnknown    Engine = "unknown"
	EngineAuto       Engine = "auto"
	EngineSQLite     Engine = "sqlite"
	EnginePostgreSQL Engine = "postgresql"
)

func CheckEngine added in v1.0.0

func CheckEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine ...Engine) (Engine, error)

CheckEngine checks if the correct database engine is used. This function stores a so called "database info file" in the database folder or checks if an existing "database info file" contains the correct engine. Otherwise the files in the database folder are not compatible.

func EngineAllowed added in v1.0.0

func EngineAllowed(dbEngine Engine, allowedEngines ...Engine) (Engine, error)

EngineAllowed checks if the database engine is allowed.

func EngineFromString added in v1.0.0

func EngineFromString(engineStr string) (Engine, error)

EngineFromString parses an engine from a string. Returns an error if the engine is unknown.

func EngineFromStringAllowed added in v1.0.0

func EngineFromStringAllowed(dbEngineStr string, allowedEngines ...Engine) (Engine, error)

EngineFromStringAllowed parses an engine from a string and checks if the database engine is allowed.

func LoadEngineFromFile added in v1.0.0

func LoadEngineFromFile(path string) (Engine, error)

LoadEngineFromFile returns the engine from the "database info file".

func NewWithDefaultSettings added in v1.0.0

func NewWithDefaultSettings(dbParams Params, createDatabaseIfNotExists bool, log *logger.Logger) (*gorm.DB, Engine, error)

type Params added in v1.0.0

type Params struct {
	Engine   Engine
	Path     string
	Host     string
	Port     uint
	Database string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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