Documentation
¶
Index ¶
- Constants
- Variables
- func Coalesce(str ...string) string
- func ColumnDoc(tableName string, colDesc *ColumnDesc) string
- func Columns(rows pgx.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 pgx.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 DBConfig
- type DBConnection
- type DBOption
- type 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) (pgconn.CommandTag, error)
- func (m *MockDBRepository) Query(ctx context.Context, query string) (pgx.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 MockRows
- func (m *MockRows) Close()
- func (m *MockRows) CommandTag() pgconn.CommandTag
- func (m *MockRows) Conn() *pgx.Conn
- func (m *MockRows) Err() error
- func (m *MockRows) FieldDescriptions() []pgconn.FieldDescription
- func (m *MockRows) Next() bool
- func (m *MockRows) RawValues() [][]byte
- func (m *MockRows) Scan(dest ...any) error
- func (m *MockRows) Values() ([]any, error)
- type Opener
- 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) (pgconn.CommandTag, error)
- func (db *PostgreSQLDBRepository) Query(ctx context.Context, query string) (pgx.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 Proto
- type SSHConfig
- 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 DBConfig ¶
type DBConfig struct {
Alias string `json:"alias" yaml:"alias"`
Driver dialect.DatabaseDriver `json:"driver" yaml:"driver"`
DataSourceName string `json:"dataSourceName" yaml:"dataSourceName"`
Proto Proto `json:"proto" yaml:"proto"`
User string `json:"user" yaml:"user"`
Passwd string `json:"passwd" yaml:"passwd"`
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Path string `json:"path" yaml:"path"`
DBName string `json:"dbName" yaml:"dbName"`
Params map[string]string `json:"params" yaml:"params"`
SSHCfg *SSHConfig `json:"sshConfig" yaml:"sshConfig"`
}
type DBConnection ¶
func Open ¶
func Open(cfg *DBConfig) (*DBConnection, error)
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) (pgconn.CommandTag, error)
Query(ctx context.Context, query string) (pgx.Rows, error)
DescribeForeignKeysBySchema(ctx context.Context, schemaName string) ([]*ForeignKey, error)
}
func CreateRepository ¶
func CreateRepository(driver dialect.DatabaseDriver, db *pgx.Conn) (DBRepository, error)
func NewMockDBRepository ¶
func NewMockDBRepository(_ *pgx.Conn) DBRepository
func NewPostgreSQLDBRepository ¶
func NewPostgreSQLDBRepository(conn *pgx.Conn) DBRepository
type Factory ¶
type Factory func(*pgx.Conn) 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) (pgconn.CommandTag, error)
MockQuery func(context.Context, string) (pgx.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) Exec ¶
func (m *MockDBRepository) Exec(ctx context.Context, query string) (pgconn.CommandTag, error)
func (*MockDBRepository) SchemaTables ¶
type MockRows ¶
type MockRows struct{}
func (*MockRows) CommandTag ¶
func (m *MockRows) CommandTag() pgconn.CommandTag
func (*MockRows) FieldDescriptions ¶
func (m *MockRows) FieldDescriptions() []pgconn.FieldDescription
type Opener ¶
type Opener func(*DBConfig) (*DBConnection, error)
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) Exec ¶
func (db *PostgreSQLDBRepository) Exec(ctx context.Context, query string) (pgconn.CommandTag, error)
func (*PostgreSQLDBRepository) SchemaTables ¶
type SSHConfig ¶
type SSHConfig struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
User string `json:"user" yaml:"user"`
PassPhrase string `json:"passPhrase" yaml:"passPhrase"`
PrivateKey string `json:"privateKey" yaml:"privateKey"`
}
func (*SSHConfig) ClientConfig ¶
func (s *SSHConfig) ClientConfig() (*ssh.ClientConfig, error)
Click to show internal directories.
Click to hide internal directories.