mysql

package
v0.0.0-...-eb3d71d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mysql provides a MySQL client to interact with a MySQL server.

Index

Constants

View Source
const (
	// User is the username used for authentication
	User = "root"
	// Pass is the password used for authentication
	Pass = "root"
)

Variables

This section is empty.

Functions

func RunServer

func RunServer(t testing.TB, serverAddr, serverPort string, withTLS bool) error

RunServer runs a MySQL server in a docker container

Types

type Client

type Client struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

Client is a MySQL client.

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient returns a new MySQL client.

func (*Client) AlterTable

func (c *Client) AlterTable() error

AlterTable alters the table.

func (*Client) CreateDB

func (c *Client) CreateDB() error

CreateDB creates a database.

func (*Client) CreateTable

func (c *Client) CreateTable() error

CreateTable creates a table.

func (*Client) DeleteFromTable

func (c *Client) DeleteFromTable(name string) error

DeleteFromTable deletes a row from the table.

func (*Client) DropDB

func (c *Client) DropDB() error

DropDB drops the database.

func (*Client) DropTable

func (c *Client) DropTable() error

DropTable drops the table.

func (*Client) InsertIntoTable

func (c *Client) InsertIntoTable(name string, population int) error

InsertIntoTable inserts a row into the table.

func (*Client) SelectAllFromTable

func (c *Client) SelectAllFromTable() error

SelectAllFromTable select all rows from the table.

func (*Client) SelectFromTable

func (c *Client) SelectFromTable(name string) (int, error)

SelectFromTable selects a row from the table.

func (*Client) UpdateTable

func (c *Client) UpdateTable(srcName, newName string, newPopulation int) error

UpdateTable updates a row in the table.

type Options

type Options struct {
	ServerAddress string
	Username      string
	Password      string
	DatabaseName  string
	Dialer        *net.Dialer
	WithTLS       bool
}

Options contains the options to connect to a MySQL server.

Jump to

Keyboard shortcuts

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