Documentation ¶
Overview ¶
Package database provides access to database schema metadata, for database/sql drivers.
Index ¶
- func InitDatabase(driverName, connectionString string) (*sql.DB, error)
- func Primarykeys(db PrimarykeyQuery, name string) ([]string, error)
- func Table(db TableNamesQuery, name string) ([]*sql.ColumnType, error)
- func TableNames(db TableNamesQuery) ([]string, error)
- func Tables(db TableNamesQuery) (map[string][]*sql.ColumnType, error)
- func View(db ViewNamesQuery, name string) ([]*sql.ColumnType, error)
- func ViewNames(db ViewNamesQuery) ([]string, error)
- func Views(db ViewNamesQuery) (map[string][]*sql.ColumnType, error)
- type DBDriver
- type DBQuery
- type Mssql
- type Mysql
- type Oracle
- type Postgres
- type PrimarykeyQuery
- type Sqlite
- type TableNamesQuery
- type ViewNamesQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDatabase ¶
InitDatabase is initialize database object.
func Primarykeys ¶
func Primarykeys(db PrimarykeyQuery, name string) ([]string, error)
Primarykeys queries the database and returns list PrimaryKey Columns.
func Table ¶
func Table(db TableNamesQuery, name string) ([]*sql.ColumnType, error)
Table returns the column type metadata for the given table name.
func TableNames ¶
func TableNames(db TableNamesQuery) ([]string, error)
TableNames returns a list of all table names in the current schema (not including system tables).
func Tables ¶
func Tables(db TableNamesQuery) (map[string][]*sql.ColumnType, error)
Tables returns column type metadata for all tables in the current schema (not including system tables). The returned map is keyed by table name. func Tables(db *sql.DB) (map[string][]*sql.ColumnType, error) {
func View ¶
func View(db ViewNamesQuery, name string) ([]*sql.ColumnType, error)
View returns the column type metadata for the given view name.
func ViewNames ¶
func ViewNames(db ViewNamesQuery) ([]string, error)
ViewNames returns a list of all view names in the current schema (not including system views).
func Views ¶
func Views(db ViewNamesQuery) (map[string][]*sql.ColumnType, error)
Views returns column type metadata for all views in the current schema (not including system views). The returned map is keyed by view name.
Types ¶
type DBDriver ¶
type DBDriver interface { // DB get database object. DB() *sql.DB // InitDB : initialize database object. InitDB(connectionString string) error // GoImport : return import path of go package. GoImport() string // returns details query table/veiw of one object. ObjectQuery() string // returns query to list table names in the current schema. TableNamesQuery() string // returns a list of all view names in the current schema. ViewNamesQuery() string // return query Get PrimaryKey Column Name. PrimarykeyQuery() string }
DBDriver interface of database object and Driver.
func GetDatabaseEngine ¶
GetDatabaseEngine : return DBEngine By name
type Mssql ¶
type Mssql struct {
// contains filtered or unexported fields
}
Mssql driver.
func (*Mssql) ObjectQuery ¶
ObjectQuery returns details query table/veiw of one object.
func (*Mssql) PrimarykeyQuery ¶
PrimarykeyQuery interface of Get PrimaryKey Column Name.
func (*Mssql) TableNamesQuery ¶
TableNamesQuery returns query to list table names in the current schema (not including system tables).
func (*Mssql) ViewNamesQuery ¶
ViewNamesQuery returns a list of all view names in the current schema (not including system views).
type Mysql ¶
type Mysql struct {
// contains filtered or unexported fields
}
Mysql driver.
func (*Mysql) ObjectQuery ¶
ObjectQuery returns details query table/veiw of one object.
func (*Mysql) PrimarykeyQuery ¶
PrimarykeyQuery interface of Get PrimaryKey Column Name.
func (*Mysql) TableNamesQuery ¶
TableNamesQuery returns query to list table names in the current schema (not including system tables).
func (*Mysql) ViewNamesQuery ¶
ViewNamesQuery returns a list of all view names in the current schema (not including system views).
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle driver.
func (*Oracle) ObjectQuery ¶
ObjectQuery returns details query table/veiw of one object.
func (*Oracle) PrimarykeyQuery ¶
PrimarykeyQuery interface of Get PrimaryKey Column Name.
func (*Oracle) TableNamesQuery ¶
TableNamesQuery returns query to list table names in the current schema (not including system tables).
func (*Oracle) ViewNamesQuery ¶
ViewNamesQuery returns a list of all view names in the current schema (not including system views).
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres driver.
func (*Postgres) ObjectQuery ¶
ObjectQuery returns details query table/veiw of one object.
func (*Postgres) PrimarykeyQuery ¶
PrimarykeyQuery return query Get PrimaryKey Column Name.
func (*Postgres) TableNamesQuery ¶
TableNamesQuery returns query to list table names in the current schema (not including system tables).
func (*Postgres) ViewNamesQuery ¶
ViewNamesQuery returns a list of all view names in the current schema (not including system views).
type PrimarykeyQuery ¶
PrimarykeyQuery return query Get PrimaryKey Column Name.
type Sqlite ¶
type Sqlite struct {
// contains filtered or unexported fields
}
Sqlite driver.
func (*Sqlite) ObjectQuery ¶
ObjectQuery returns details query table/veiw of one object.
func (*Sqlite) PrimarykeyQuery ¶
PrimarykeyQuery interface of Get PrimaryKey Column Name.
func (*Sqlite) TableNamesQuery ¶
TableNamesQuery returns query to list table names in the current schema (not including system tables).
func (*Sqlite) ViewNamesQuery ¶
ViewNamesQuery returns a list of all view names in the current schema (not including system views).
type TableNamesQuery ¶
TableNamesQuery interface of DBDriver and TableNamesQuery.