database

package
v0.0.0-...-5d77e96 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQL

type MySQL struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string

	Conn *sql.DB
}

MySQL is an implementation of the Database interface

func FromEnvironment

func FromEnvironment() (*MySQL, error)

func New

func New(host, user, password string) (*MySQL, error)

func (*MySQL) Connect

func (m *MySQL) Connect() error

Connect connects to the MySQL database

func (*MySQL) Connection

func (m *MySQL) Connection() *sql.DB

func (*MySQL) CreateAndUseDB

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

Helper function to create and use a database in one go

func (*MySQL) CreateDatabase

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

CreateDatabase creates the database

func (*MySQL) CreateTable

func (m *MySQL) CreateTable(name string, columns []string) error

CreateTable creates a table in the database

func (*MySQL) CreateUser

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

func (*MySQL) Delete

func (m *MySQL) Delete(table string, where string) error

func (*MySQL) DescribeTable

func (m *MySQL) DescribeTable(name string) (*sql.Rows, error)

func (*MySQL) Disconnect

func (m *MySQL) Disconnect() error

Disconnect disconnects from the MySQL database

func (*MySQL) DropDatabase

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

func (*MySQL) DropTable

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

func (*MySQL) Insert

func (m *MySQL) Insert(table string, columns []string, values []string) error

func (*MySQL) Ping

func (m *MySQL) Ping() error

func (*MySQL) Query

func (m *MySQL) Query(query string) (*sql.Rows, error)

func (*MySQL) Select

func (m *MySQL) Select(table string, columns []string, where string) (*sql.Rows, error)

func (*MySQL) ShowDatabases

func (m *MySQL) ShowDatabases() (*sql.Rows, error)

func (*MySQL) ShowTables

func (m *MySQL) ShowTables() (*sql.Rows, error)

func (*MySQL) TruncateTable

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

func (*MySQL) Update

func (m *MySQL) Update(table string, columns []string, values []string, where string) error

func (*MySQL) UseDatabase

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

func (*MySQL) WhereAmI

func (m *MySQL) WhereAmI() string

Returns the current database name

if there is an error, it will return "<ERROR>"

if we are not inside a database, it will return "<NO DATABASE>"

Jump to

Keyboard shortcuts

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