Documentation ¶
Index ¶
- Constants
- Variables
- func Coalesce(str ...string) string
- func ColumnDoc(tableName string, colDesc *ColumnDesc) string
- func Columns(rows *sql.Rows) ([]string, error)
- func QueryExecType(prefix, sqlstr string) (string, bool)
- func RegisterFactory(name dialect.DatabaseDriver, factory Factory)
- func RegisterOpen(name dialect.DatabaseDriver, opener Opener)
- func Registered(name dialect.DatabaseDriver) bool
- func ScanRows(rows *sql.Rows, columnLength int) ([][]string, error)
- func SubqueryColumnDoc(identName string, views []*parseutil.SubQueryView, dbCache *DBCache) string
- func SubqueryDoc(name string, views []*parseutil.SubQueryView, dbCache *DBCache) string
- func TableDoc(tableName string, cols []*ColumnDesc) string
- type ColumnBase
- type ColumnDesc
- type DBCache
- func (dc *DBCache) Column(tableName, colName string) (*ColumnDesc, bool)
- func (dc *DBCache) ColumnDatabase(dbName, tableName string) (cols []*ColumnDesc, ok bool)
- func (dc *DBCache) ColumnDescs(tableName string) (cols []*ColumnDesc, ok bool)
- func (dc *DBCache) Database(dbName string) (db string, ok bool)
- func (dc *DBCache) SortedSchemas() []string
- func (dc *DBCache) SortedTables() []string
- func (dc *DBCache) SortedTablesByDBName(dbName string) (tbls []string, ok bool)
- type DBCacheGenerator
- type DBConnection
- type DBOption
- type DBRepository
- func CreateRepository(driver dialect.DatabaseDriver, db *sql.DB) (DBRepository, error)
- func NewMockDBRepository(_ *sql.DB) DBRepository
- func NewMssqlDBRepository(conn *sql.DB) DBRepository
- func NewMySQLDBRepository(conn *sql.DB) DBRepository
- func NewOracleDBRepository(conn *sql.DB) DBRepository
- func NewPostgreSQLDBRepository(conn *sql.DB) DBRepository
- func NewSQLite3DBRepository(conn *sql.DB) DBRepository
- type Factory
- type ForeignKey
- type MockDBRepository
- func (m *MockDBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (m *MockDBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (m *MockDBRepository) Databases(ctx context.Context) ([]string, error)
- func (m *MockDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (m *MockDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
- func (m *MockDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (m *MockDBRepository) Driver() dialect.DatabaseDriver
- func (m *MockDBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (m *MockDBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (m *MockDBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (m *MockDBRepository) Schemas(ctx context.Context) ([]string, error)
- func (m *MockDBRepository) Tables(ctx context.Context) ([]string, error)
- type MockResult
- type MssqlDBRepository
- func (db *MssqlDBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (db *MssqlDBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (db *MssqlDBRepository) Databases(ctx context.Context) ([]string, error)
- func (db *MssqlDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (db *MssqlDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
- func (db *MssqlDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (db *MssqlDBRepository) Driver() dialect.DatabaseDriver
- func (db *MssqlDBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (db *MssqlDBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (db *MssqlDBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (db *MssqlDBRepository) Schemas(ctx context.Context) ([]string, error)
- func (db *MssqlDBRepository) Tables(ctx context.Context) ([]string, error)
- type MySQLDBRepository
- func (db *MySQLDBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (db *MySQLDBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (db *MySQLDBRepository) Databases(ctx context.Context) ([]string, error)
- func (db *MySQLDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (db *MySQLDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
- func (db *MySQLDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (db *MySQLDBRepository) Driver() dialect.DatabaseDriver
- func (db *MySQLDBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (db *MySQLDBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (db *MySQLDBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (db *MySQLDBRepository) Schemas(ctx context.Context) ([]string, error)
- func (db *MySQLDBRepository) Tables(ctx context.Context) ([]string, error)
- type MySQLViaSSHDialer
- type Opener
- type OracleDBRepository
- func (db *OracleDBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (db *OracleDBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (db *OracleDBRepository) Databases(ctx context.Context) ([]string, error)
- func (db *OracleDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (db *OracleDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
- func (db *OracleDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (db *OracleDBRepository) Driver() dialect.DatabaseDriver
- func (db *OracleDBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (db *OracleDBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (db *OracleDBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (db *OracleDBRepository) Schemas(ctx context.Context) ([]string, error)
- func (db *OracleDBRepository) Tables(ctx context.Context) ([]string, error)
- type PostgreSQLDBRepository
- func (db *PostgreSQLDBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (db *PostgreSQLDBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (db *PostgreSQLDBRepository) Databases(ctx context.Context) ([]string, error)
- func (db *PostgreSQLDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (db *PostgreSQLDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
- func (db *PostgreSQLDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (db *PostgreSQLDBRepository) Driver() dialect.DatabaseDriver
- func (db *PostgreSQLDBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (db *PostgreSQLDBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (db *PostgreSQLDBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (db *PostgreSQLDBRepository) Schemas(ctx context.Context) ([]string, error)
- func (db *PostgreSQLDBRepository) Tables(ctx context.Context) ([]string, error)
- type SQLite3DBRepository
- func (db *SQLite3DBRepository) CurrentDatabase(ctx context.Context) (string, error)
- func (db *SQLite3DBRepository) CurrentSchema(ctx context.Context) (string, error)
- func (db *SQLite3DBRepository) Databases(ctx context.Context) ([]string, error)
- func (db *SQLite3DBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
- func (db *SQLite3DBRepository) DescribeDatabaseTableBySchema(ctx context.Context, _ string) ([]*ColumnDesc, error)
- func (db *SQLite3DBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
- func (db *SQLite3DBRepository) Driver() dialect.DatabaseDriver
- func (db *SQLite3DBRepository) Exec(ctx context.Context, query string) (sql.Result, error)
- func (db *SQLite3DBRepository) Query(ctx context.Context, query string) (*sql.Rows, error)
- func (db *SQLite3DBRepository) SchemaTables(ctx context.Context) (map[string][]string, error)
- func (db *SQLite3DBRepository) Schemas(ctx context.Context) ([]string, error)
- func (db *SQLite3DBRepository) Tables(ctx context.Context) ([]string, error)
- type Worker
Constants ¶
View Source
const ( DefaultMaxIdleConns = 10 DefaultMaxOpenConns = 5 )
Variables ¶
View Source
var (
ErrNotImplementation error = errors.New("not implementation")
)
Functions ¶
func ColumnDoc ¶
func ColumnDoc(tableName string, colDesc *ColumnDesc) string
func QueryExecType ¶
QueryExecType is the default way to determine the "EXEC" prefix for a SQL query and whether or not it should be Exec'd or Query'd.
func RegisterFactory ¶
func RegisterFactory(name dialect.DatabaseDriver, factory Factory)
func RegisterOpen ¶
func RegisterOpen(name dialect.DatabaseDriver, opener Opener)
func Registered ¶
func Registered(name dialect.DatabaseDriver) bool
func SubqueryColumnDoc ¶
func SubqueryColumnDoc(identName string, views []*parseutil.SubQueryView, dbCache *DBCache) string
func SubqueryDoc ¶
func SubqueryDoc(name string, views []*parseutil.SubQueryView, dbCache *DBCache) string
func TableDoc ¶
func TableDoc(tableName string, cols []*ColumnDesc) string
Types ¶
type ColumnBase ¶
type ColumnDesc ¶
type ColumnDesc struct { ColumnBase Type string Null string Key string Default sql.NullString Extra string }
func (*ColumnDesc) OnelineDesc ¶
func (cd *ColumnDesc) OnelineDesc() string
type DBCache ¶
type DBCache struct { Schemas map[string]string SchemaTables map[string][]string ColumnsWithParent map[string][]*ColumnDesc ForeignKeys map[string]map[string][]*ForeignKey // contains filtered or unexported fields }
func (*DBCache) ColumnDatabase ¶
func (dc *DBCache) ColumnDatabase(dbName, tableName string) (cols []*ColumnDesc, ok bool)
func (*DBCache) ColumnDescs ¶
func (dc *DBCache) ColumnDescs(tableName string) (cols []*ColumnDesc, ok bool)
func (*DBCache) SortedSchemas ¶
func (*DBCache) SortedTables ¶
type DBCacheGenerator ¶
type DBCacheGenerator struct {
// contains filtered or unexported fields
}
func NewDBCacheUpdater ¶
func NewDBCacheUpdater(repo DBRepository) *DBCacheGenerator
func (*DBCacheGenerator) GenerateDBCachePrimary ¶
func (u *DBCacheGenerator) GenerateDBCachePrimary(ctx context.Context) (*DBCache, error)
func (*DBCacheGenerator) GenerateDBCacheSecondary ¶
func (u *DBCacheGenerator) GenerateDBCacheSecondary(ctx context.Context) (map[string][]*ColumnDesc, error)
type DBConnection ¶
func (*DBConnection) Close ¶
func (db *DBConnection) Close() error
type DBRepository ¶
type DBRepository interface { Driver() dialect.DatabaseDriver CurrentDatabase(ctx context.Context) (string, error) Databases(ctx context.Context) ([]string, error) CurrentSchema(ctx context.Context) (string, error) Schemas(ctx context.Context) ([]string, error) SchemaTables(ctx context.Context) (map[string][]string, error) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error) Exec(ctx context.Context, query string) (sql.Result, error) Query(ctx context.Context, query string) (*sql.Rows, error) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error) }
func CreateRepository ¶
func CreateRepository(driver dialect.DatabaseDriver, db *sql.DB) (DBRepository, error)
func NewMockDBRepository ¶
func NewMockDBRepository(_ *sql.DB) DBRepository
func NewMssqlDBRepository ¶
func NewMssqlDBRepository(conn *sql.DB) DBRepository
func NewMySQLDBRepository ¶
func NewMySQLDBRepository(conn *sql.DB) DBRepository
func NewOracleDBRepository ¶
func NewOracleDBRepository(conn *sql.DB) DBRepository
func NewPostgreSQLDBRepository ¶
func NewPostgreSQLDBRepository(conn *sql.DB) DBRepository
func NewSQLite3DBRepository ¶
func NewSQLite3DBRepository(conn *sql.DB) DBRepository
type Factory ¶
type Factory func(*sql.DB) DBRepository
type ForeignKey ¶
type ForeignKey [][2]*ColumnBase
type MockDBRepository ¶
type MockDBRepository struct { MockDatabase func(context.Context) (string, error) MockDatabases func(context.Context) ([]string, error) MockDatabaseTables func(context.Context) (map[string][]string, error) MockTables func(context.Context) ([]string, error) MockDescribeTable func(context.Context, string) ([]*ColumnDesc, error) MockDescribeDatabaseTable func(context.Context) ([]*ColumnDesc, error) MockDescribeDatabaseTableBySchema func(context.Context, string) ([]*ColumnDesc, error) MockExec func(context.Context, string) (sql.Result, error) MockQuery func(context.Context, string) (*sql.Rows, error) MockDescribeForeignKeysBySchema func(context.Context, string) ([]*ForeignKey, error) }
func (*MockDBRepository) CurrentDatabase ¶
func (m *MockDBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*MockDBRepository) CurrentSchema ¶
func (m *MockDBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*MockDBRepository) Databases ¶
func (m *MockDBRepository) Databases(ctx context.Context) ([]string, error)
func (*MockDBRepository) DescribeDatabaseTable ¶
func (m *MockDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*MockDBRepository) DescribeDatabaseTableBySchema ¶
func (m *MockDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
func (*MockDBRepository) DescribeForeignKeysBySchema ¶
func (m *MockDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*MockDBRepository) Driver ¶
func (m *MockDBRepository) Driver() dialect.DatabaseDriver
func (*MockDBRepository) SchemaTables ¶
type MockResult ¶
type MockResult struct { MockLastInsertID func() (int64, error) MockRowsAffected func() (int64, error) }
func (*MockResult) LastInsertId ¶
func (m *MockResult) LastInsertId() (int64, error)
func (*MockResult) RowsAffected ¶
func (m *MockResult) RowsAffected() (int64, error)
type MssqlDBRepository ¶
func (*MssqlDBRepository) CurrentDatabase ¶
func (db *MssqlDBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*MssqlDBRepository) CurrentSchema ¶
func (db *MssqlDBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*MssqlDBRepository) Databases ¶
func (db *MssqlDBRepository) Databases(ctx context.Context) ([]string, error)
func (*MssqlDBRepository) DescribeDatabaseTable ¶
func (db *MssqlDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*MssqlDBRepository) DescribeDatabaseTableBySchema ¶
func (db *MssqlDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
func (*MssqlDBRepository) DescribeForeignKeysBySchema ¶
func (db *MssqlDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*MssqlDBRepository) Driver ¶
func (db *MssqlDBRepository) Driver() dialect.DatabaseDriver
func (*MssqlDBRepository) SchemaTables ¶
type MySQLDBRepository ¶
func (*MySQLDBRepository) CurrentDatabase ¶
func (db *MySQLDBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*MySQLDBRepository) CurrentSchema ¶
func (db *MySQLDBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*MySQLDBRepository) Databases ¶
func (db *MySQLDBRepository) Databases(ctx context.Context) ([]string, error)
func (*MySQLDBRepository) DescribeDatabaseTable ¶
func (db *MySQLDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*MySQLDBRepository) DescribeDatabaseTableBySchema ¶
func (db *MySQLDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
func (*MySQLDBRepository) DescribeForeignKeysBySchema ¶
func (db *MySQLDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*MySQLDBRepository) Driver ¶
func (db *MySQLDBRepository) Driver() dialect.DatabaseDriver
func (*MySQLDBRepository) SchemaTables ¶
type MySQLViaSSHDialer ¶
type MySQLViaSSHDialer struct {
// contains filtered or unexported fields
}
type OracleDBRepository ¶
func (*OracleDBRepository) CurrentDatabase ¶
func (db *OracleDBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*OracleDBRepository) CurrentSchema ¶
func (db *OracleDBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*OracleDBRepository) Databases ¶
func (db *OracleDBRepository) Databases(ctx context.Context) ([]string, error)
func (*OracleDBRepository) DescribeDatabaseTable ¶
func (db *OracleDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*OracleDBRepository) DescribeDatabaseTableBySchema ¶
func (db *OracleDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
func (*OracleDBRepository) DescribeForeignKeysBySchema ¶
func (db *OracleDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*OracleDBRepository) Driver ¶
func (db *OracleDBRepository) Driver() dialect.DatabaseDriver
func (*OracleDBRepository) SchemaTables ¶
type PostgreSQLDBRepository ¶
func (*PostgreSQLDBRepository) CurrentDatabase ¶
func (db *PostgreSQLDBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*PostgreSQLDBRepository) CurrentSchema ¶
func (db *PostgreSQLDBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*PostgreSQLDBRepository) Databases ¶
func (db *PostgreSQLDBRepository) Databases(ctx context.Context) ([]string, error)
func (*PostgreSQLDBRepository) DescribeDatabaseTable ¶
func (db *PostgreSQLDBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*PostgreSQLDBRepository) DescribeDatabaseTableBySchema ¶
func (db *PostgreSQLDBRepository) DescribeDatabaseTableBySchema(ctx context.Context, schemaName string) ([]*ColumnDesc, error)
func (*PostgreSQLDBRepository) DescribeForeignKeysBySchema ¶
func (db *PostgreSQLDBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*PostgreSQLDBRepository) Driver ¶
func (db *PostgreSQLDBRepository) Driver() dialect.DatabaseDriver
func (*PostgreSQLDBRepository) SchemaTables ¶
type SQLite3DBRepository ¶
func (*SQLite3DBRepository) CurrentDatabase ¶
func (db *SQLite3DBRepository) CurrentDatabase(ctx context.Context) (string, error)
func (*SQLite3DBRepository) CurrentSchema ¶
func (db *SQLite3DBRepository) CurrentSchema(ctx context.Context) (string, error)
func (*SQLite3DBRepository) Databases ¶
func (db *SQLite3DBRepository) Databases(ctx context.Context) ([]string, error)
func (*SQLite3DBRepository) DescribeDatabaseTable ¶
func (db *SQLite3DBRepository) DescribeDatabaseTable(ctx context.Context) ([]*ColumnDesc, error)
func (*SQLite3DBRepository) DescribeDatabaseTableBySchema ¶
func (db *SQLite3DBRepository) DescribeDatabaseTableBySchema(ctx context.Context, _ string) ([]*ColumnDesc, error)
func (*SQLite3DBRepository) DescribeForeignKeysBySchema ¶
func (db *SQLite3DBRepository) DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
func (*SQLite3DBRepository) Driver ¶
func (db *SQLite3DBRepository) Driver() dialect.DatabaseDriver
func (*SQLite3DBRepository) SchemaTables ¶
Click to show internal directories.
Click to hide internal directories.