Documentation ¶
Index ¶
- Constants
- type Driver
- type FKDescriptor
- type Field
- type FieldDescriptor
- type Flags
- type MySQL
- func (m MySQL) Connection() string
- func (MySQL) Describe(table string, db *sql.DB) ([]FieldDescriptor, error)
- func (m MySQL) Driver() string
- func (MySQL) GetLatestColumnValue(table, column string, db *sql.DB) (interface{}, error)
- func (MySQL) GetTestCase(name string) (TestCase, error)
- func (m MySQL) Insert(fields []string, table string) string
- func (m MySQL) MapField(descriptor FieldDescriptor) Field
- func (m MySQL) MultiDescribe(tables []string, db *sql.DB) (map[string][]FieldDescriptor, []string, error)
- func (m MySQL) ShowTables(db *sql.DB) ([]string, error)
- func (m MySQL) TestTable(db *sql.DB, testCase, table string) error
- type Postgres
- func (p Postgres) Connection() string
- func (p Postgres) Describe(table string, db *sql.DB) ([]FieldDescriptor, error)
- func (p Postgres) Driver() string
- func (p Postgres) GetLatestColumnValue(table, column string, db *sql.DB) (interface{}, error)
- func (Postgres) GetTestCase(name string) (TestCase, error)
- func (p Postgres) Insert(fields []string, table string) string
- func (p Postgres) MapField(descriptor FieldDescriptor) Field
- func (p Postgres) MultiDescribe(tables []string, db *sql.DB) (map[string][]FieldDescriptor, []string, error)
- func (p Postgres) ShowTables(db *sql.DB) ([]string, error)
- func (p Postgres) TestTable(db *sql.DB, testCase, table string) error
- type TestCase
- type Testable
- type Type
Examples ¶
Constants ¶
View Source
const ( PSQLDescribeTemplate = "" /* 172-byte string literal not displayed */ PSQLConnectionTemplate = "host=%s port=%s user=%s password=%s dbname=%s sslmode=disable" PSQLInsertTemplate = `INSERT INTO %s("%s") VALUES(%s)` PSQLShowTablesQuery = "SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" )
View Source
const CreateTable = `` /* 1246-byte string literal not displayed */
Below columns are not yet implemented and removed from table. Add these once implemented. col20 cidr col24 inet col30 line col31 macaddr col32 money
View Source
const (
DefaultTableCreateQueryKey = ""
)
View Source
const (
MySQLDescribeTableQuery = "SHOW TABLES;"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface { ShowTables(db *sql.DB) ([]string, error) Connection() string Driver() string Insert(fields []string, table string) string MapField(descriptor FieldDescriptor) Field Describe(table string, db *sql.DB) ([]FieldDescriptor, error) MultiDescribe(tables []string, db *sql.DB) (map[string][]FieldDescriptor, []string, error) GetLatestColumnValue(table, column string, db *sql.DB) (interface{}, error) }
Driver is the interface should satisfied by a certain driver
type FKDescriptor ¶ added in v0.5.0
type FieldDescriptor ¶ added in v0.4.0
type FieldDescriptor struct { Field string Type string Null string Key string Length null.Int Default null.String Extra string Precision null.Int Scale null.Int HasDefaultValue bool ForeignKeyDescriptor *FKDescriptor }
FieldDescriptor represents a field described by the table in the SQL database
type Flags ¶
type Flags struct { Username string Password string Database string Host string Port string Driver string }
Flags needed by the driver
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
MySQL implementation of the Driver
func (MySQL) Connection ¶
Connection returns the specific connection string
func (MySQL) GetLatestColumnValue ¶ added in v0.5.0
func (MySQL) MapField ¶
func (m MySQL) MapField(descriptor FieldDescriptor) Field
MapField returns the actual fields
func (MySQL) MultiDescribe ¶ added in v0.5.0
type Postgres ¶ added in v0.4.0
type Postgres struct {
// contains filtered or unexported fields
}
func (Postgres) Connection ¶ added in v0.4.0
func (Postgres) GetLatestColumnValue ¶ added in v0.5.0
func (Postgres) GetTestCase ¶ added in v0.5.0
func (Postgres) MapField ¶ added in v0.4.0
func (p Postgres) MapField(descriptor FieldDescriptor) Field
func (Postgres) MultiDescribe ¶ added in v0.5.0
func (Postgres) ShowTables ¶ added in v0.4.0
Example ¶
createTable() db, err := getPostgresConnection() if err != nil { return } driver := Postgres{} tables, err := driver.ShowTables(db) if err != nil { log.Printf("Error showing tables : %s", err.Error()) return } for _, table := range tables { fmt.Println(table) }
Output:
type TestCase ¶ added in v0.5.0
TestCase has a map of table to its create table query and table creation order
Click to show internal directories.
Click to hide internal directories.