drivers

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2016 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MySQLBuildQueryString

func MySQLBuildQueryString(user, pass, dbname, host string, port int, sslmode string) string

MySQLBuildQueryString builds a query string for MySQL.

func PostgresBuildQueryString

func PostgresBuildQueryString(user, pass, dbname, host string, port int, sslmode string) string

PostgresBuildQueryString builds a query string.

Types

type MockDriver

type MockDriver struct{}

MockDriver is a mock implementation of the bdb driver Interface

func (*MockDriver) Close

func (m *MockDriver) Close()

Close mimics a database close call

func (*MockDriver) Columns

func (m *MockDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns returns a list of mock columns

func (*MockDriver) ForeignKeyInfo

func (m *MockDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo returns a list of mock foreignkeys

func (*MockDriver) IndexPlaceholders

func (m *MockDriver) IndexPlaceholders() bool

IndexPlaceholders returns true to indicate fake support of indexed placeholders

func (*MockDriver) LeftQuote

func (m *MockDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*MockDriver) Open

func (m *MockDriver) Open() error

Open mimics a database open call and returns nil for no error

func (*MockDriver) PrimaryKeyInfo

func (m *MockDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo returns mock primary key info for the passed in table name

func (*MockDriver) RightQuote

func (m *MockDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*MockDriver) TableNames

func (m *MockDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames returns a list of mock table names

func (*MockDriver) TranslateColumnType

func (m *MockDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts a column to its "null." form if it is nullable

func (*MockDriver) UseLastInsertID

func (m *MockDriver) UseLastInsertID() bool

UseLastInsertID returns a database mock LastInsertID compatibility flag

type MySQLDriver

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

MySQLDriver holds the database connection string and a handle to the database connection.

func NewMySQLDriver

func NewMySQLDriver(user, pass, dbname, host string, port int, sslmode string) *MySQLDriver

NewMySQLDriver takes the database connection details as parameters and returns a pointer to a MySQLDriver object. Note that it is required to call MySQLDriver.Open() and MySQLDriver.Close() to open and close the database connection once an object has been obtained.

func (*MySQLDriver) Close

func (m *MySQLDriver) Close()

Close closes the database connection

func (*MySQLDriver) Columns

func (m *MySQLDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns takes a table name and attempts to retrieve the table information from the database information_schema.columns. It retrieves the column names and column types and returns those as a []Column after TranslateColumnType() converts the SQL types to Go types, for example: "varchar" to "string"

func (*MySQLDriver) ForeignKeyInfo

func (m *MySQLDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo retrieves the foreign keys for a given table name.

func (*MySQLDriver) IndexPlaceholders

func (m *MySQLDriver) IndexPlaceholders() bool

IndexPlaceholders returns false to indicate MySQL doesnt support indexed placeholders

func (*MySQLDriver) LeftQuote

func (m *MySQLDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*MySQLDriver) Open

func (m *MySQLDriver) Open() error

Open opens the database connection using the connection string

func (*MySQLDriver) PrimaryKeyInfo

func (m *MySQLDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo looks up the primary key for a table.

func (*MySQLDriver) RightQuote

func (m *MySQLDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*MySQLDriver) TableNames

func (m *MySQLDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames connects to the postgres database and retrieves all table names from the information_schema where the table schema is public.

func (*MySQLDriver) TranslateColumnType

func (m *MySQLDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts postgres database types to Go types, for example "varchar" to "string" and "bigint" to "int64". It returns this parsed data as a Column object.

func (*MySQLDriver) UseLastInsertID

func (m *MySQLDriver) UseLastInsertID() bool

UseLastInsertID returns false for postgres

type PostgresDriver

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

PostgresDriver holds the database connection string and a handle to the database connection.

func NewPostgresDriver

func NewPostgresDriver(user, pass, dbname, host string, port int, sslmode string) *PostgresDriver

NewPostgresDriver takes the database connection details as parameters and returns a pointer to a PostgresDriver object. Note that it is required to call PostgresDriver.Open() and PostgresDriver.Close() to open and close the database connection once an object has been obtained.

func (*PostgresDriver) Close

func (p *PostgresDriver) Close()

Close closes the database connection

func (*PostgresDriver) Columns

func (p *PostgresDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns takes a table name and attempts to retrieve the table information from the database information_schema.columns. It retrieves the column names and column types and returns those as a []Column after TranslateColumnType() converts the SQL types to Go types, for example: "varchar" to "string"

func (*PostgresDriver) ForeignKeyInfo

func (p *PostgresDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo retrieves the foreign keys for a given table name.

func (*PostgresDriver) IndexPlaceholders

func (p *PostgresDriver) IndexPlaceholders() bool

IndexPlaceholders returns true to indicate PSQL supports indexed placeholders

func (*PostgresDriver) LeftQuote

func (p *PostgresDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*PostgresDriver) Open

func (p *PostgresDriver) Open() error

Open opens the database connection using the connection string

func (*PostgresDriver) PrimaryKeyInfo

func (p *PostgresDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo looks up the primary key for a table.

func (*PostgresDriver) RightQuote

func (p *PostgresDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*PostgresDriver) TableNames

func (p *PostgresDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames connects to the postgres database and retrieves all table names from the information_schema where the table schema is schema. It uses a whitelist and blacklist.

func (*PostgresDriver) TranslateColumnType

func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts postgres database types to Go types, for example "varchar" to "string" and "bigint" to "int64". It returns this parsed data as a Column object.

func (*PostgresDriver) UseLastInsertID

func (p *PostgresDriver) UseLastInsertID() bool

UseLastInsertID returns false for postgres

Jump to

Keyboard shortcuts

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