dbman

package
v0.0.0-...-4feb759 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const NameMySQL = "mysql"
View Source
const NamePostgreSQL = "postgres"

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {

	// Name returns the unique identifier for the database server.
	Name() string

	// Title returns the human-readable name of the database server.
	Title() string

	// Version returns the version string for the database server.
	Version() string

	// CreateUser ensures that the specified user exists, creating them if not using the provided password.
	CreateUser(username, password string) error

	// CreateDatabase ensures that the specified database exists, creating it if not using the provided owner.
	CreateDatabase(name, user string) error

	// ListDatabases returns a list of databases in the database server.
	ListDatabases() ([]string, error)

	// DeleteDatabase removes the specified database.
	DeleteDatabase(name string) error

	// Shut down the connection to the database server.
	Close()
}

Database provides a generic interface for working with a database server.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages connections to database servers.

func NewManager

func NewManager() *Manager

NewManager creates a new database manager.

func (*Manager) Get

func (m *Manager) Get(name string) (Database, error)

Get attempts to retrieve the specified database driver.

func (*Manager) List

func (m *Manager) List() []Database

List returns a slice of all registered databases.

func (*Manager) Register

func (m *Manager) Register(database Database)

Register adds the database to the manager.

type MySQL

type MySQL struct {
	// contains filtered or unexported fields
}

MySQL provides access to a MySQL database.

func NewMySQL

func NewMySQL(host string, port int, user, password string) (*MySQL, error)

NewMySQL attempts to create a connection to a MySQL database.

func (*MySQL) Close

func (m *MySQL) Close()

func (*MySQL) CreateDatabase

func (m *MySQL) CreateDatabase(name, user string) error

func (*MySQL) CreateUser

func (m *MySQL) CreateUser(user, password string) error

func (*MySQL) DeleteDatabase

func (m *MySQL) DeleteDatabase(name string) error

func (*MySQL) ListDatabases

func (m *MySQL) ListDatabases() ([]string, error)

func (*MySQL) Name

func (m *MySQL) Name() string

func (*MySQL) Title

func (m *MySQL) Title() string

func (*MySQL) Version

func (m *MySQL) Version() string

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

Postgres provides access to a PostgreSQL database.

func NewPostgres

func NewPostgres(host string, port int, user, password string) (*Postgres, error)

NewPostgres attempts to create a connection to a PostgreSQL database. The server version is retrieved as well.

func (*Postgres) Close

func (p *Postgres) Close()

func (*Postgres) CreateDatabase

func (p *Postgres) CreateDatabase(name, user string) error

func (*Postgres) CreateUser

func (p *Postgres) CreateUser(user, password string) error

func (*Postgres) DeleteDatabase

func (p *Postgres) DeleteDatabase(name string) error

func (*Postgres) ListDatabases

func (p *Postgres) ListDatabases() ([]string, error)

func (*Postgres) Name

func (p *Postgres) Name() string

func (*Postgres) Title

func (p *Postgres) Title() string

func (*Postgres) Version

func (p *Postgres) Version() string

Jump to

Keyboard shortcuts

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