dboperator

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	ColumnName string // 列名
	Comment    string // 注释
	DataType   string // 数据类型

}

type GPOperator

type GPOperator struct{}

func (GPOperator) Close

func (G GPOperator) Close(dbName string) error

func (GPOperator) CreateSchema

func (G GPOperator) CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)

func (GPOperator) ExecuteDDL

func (G GPOperator) ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)

func (GPOperator) GetColumns

func (G GPOperator) GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)

func (GPOperator) GetColumnsUnderTables

func (G GPOperator) GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)

func (GPOperator) GetDataBySQL

func (G GPOperator) GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)

func (GPOperator) GetTableData

func (G GPOperator) GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)

func (GPOperator) GetTablesUnderDB

func (G GPOperator) GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)

func (GPOperator) Open

func (G GPOperator) Open(config *gormx.Config) error

func (GPOperator) Ping

func (G GPOperator) Ping(dbName string) error

type GormDBTable

type GormDBTable struct {
	TableSchema string `db:"table_schema"`
	TableName   string `db:"table_name"`
	Comments    string `db:"comments"`
}

type GormTableColumn

type GormTableColumn struct {
	TableSchema string `db:"table_schema"`
	TableName   string `db:"table_name"`
	ColumnName  string `db:"column_name"`
	Comments    string `db:"comments"`
	DataType    string `db:"data_type"`
}

type IConnector

type IConnector interface {
	Open(config *gormx.Config) error
	Ping(dbName string) error
	Close(dbName string) error
}

IConnector 数据库连接器接口

type IDataExplorer

type IDataExplorer interface {
	// GetTablesUnderDB 获取该库下所有逻辑库及表名
	GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)
	// GetColumns 获取指定库所有逻辑库及表下字段列表
	GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)
	// GetColumnsUnderTables 获取指定库表下字段列表
	GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)
	// CreateSchema 创建逻辑库
	CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)
	// ExecuteDDL 执行DDL
	ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)
	// GetDataBySQL 执行自定义
	GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)
	// GetTableData 执行查询表数据, pageInfo为nil时不分页
	GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)
}

IDataExplorer 数据探查

type IOperator

type IOperator interface {
	IConnector
	IDataExplorer
}

func NewGPOperator

func NewGPOperator() IOperator

func NewMySQLOperator

func NewMySQLOperator() IOperator

func NewOracleOperator

func NewOracleOperator() IOperator

func NewPGOperator

func NewPGOperator() IOperator

func NewSqlserverOperator

func NewSqlserverOperator() IOperator

type LogicDBInfo

type LogicDBInfo struct {
	SchemaName    string
	TableInfoList []*TableInfo
}

type MySQLOperator

type MySQLOperator struct{}

func (MySQLOperator) Close

func (m MySQLOperator) Close(dbName string) error

func (MySQLOperator) CreateSchema

func (m MySQLOperator) CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)

func (MySQLOperator) ExecuteDDL

func (m MySQLOperator) ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)

func (MySQLOperator) GetColumns

func (m MySQLOperator) GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)

func (MySQLOperator) GetColumnsUnderTables

func (m MySQLOperator) GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)

func (MySQLOperator) GetDataBySQL

func (m MySQLOperator) GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)

func (MySQLOperator) GetTableData

func (m MySQLOperator) GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)

func (MySQLOperator) GetTablesUnderDB

func (m MySQLOperator) GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)

func (MySQLOperator) Open

func (m MySQLOperator) Open(config *gormx.Config) error

func (MySQLOperator) Ping

func (m MySQLOperator) Ping(dbName string) error

type OracleOperator

type OracleOperator struct{}

func (OracleOperator) Close

func (o OracleOperator) Close(dbName string) error

func (OracleOperator) CreateSchema

func (o OracleOperator) CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)

func (OracleOperator) ExecuteDDL

func (o OracleOperator) ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)

func (OracleOperator) GetColumns

func (o OracleOperator) GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)

func (OracleOperator) GetColumnsUnderTables

func (o OracleOperator) GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)

func (OracleOperator) GetDataBySQL

func (o OracleOperator) GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)

func (OracleOperator) GetTableData

func (o OracleOperator) GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)

func (OracleOperator) GetTablesUnderDB

func (o OracleOperator) GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)

func (OracleOperator) Open

func (o OracleOperator) Open(config *gormx.Config) error

func (OracleOperator) Ping

func (o OracleOperator) Ping(dbName string) error

type PGOperator

type PGOperator struct{}

func (PGOperator) Close

func (P PGOperator) Close(dbName string) error

func (PGOperator) CreateSchema

func (P PGOperator) CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)

func (PGOperator) ExecuteDDL

func (P PGOperator) ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)

func (PGOperator) GetColumns

func (P PGOperator) GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)

func (PGOperator) GetColumnsUnderTables

func (P PGOperator) GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)

func (PGOperator) GetDataBySQL

func (P PGOperator) GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)

func (PGOperator) GetTableData

func (P PGOperator) GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)

func (PGOperator) GetTablesUnderDB

func (P PGOperator) GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)

func (PGOperator) Open

func (P PGOperator) Open(config *gormx.Config) error

func (PGOperator) Ping

func (P PGOperator) Ping(dbName string) error

type Pagination

type Pagination struct {
	Page      int64 `json:"page"`       // 当前页
	PageSize  int64 `json:"page_size"`  // 每页多少条记录
	PageCount int64 `json:"page_count"` // 一共多少页
	Total     int64 `json:"total"`      // 一共多少条记录
}

Pagination 分页结构体(该分页只适合数据量很少的情况)

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() (offset int64)

func (*Pagination) SetPageCount

func (p *Pagination) SetPageCount()

type SqlServerOperator

type SqlServerOperator struct{}

func (SqlServerOperator) Close

func (s SqlServerOperator) Close(dbName string) error

func (SqlServerOperator) CreateSchema

func (s SqlServerOperator) CreateSchema(ctx context.Context, dbName, schemaName, commentInfo string) (err error)

func (SqlServerOperator) ExecuteDDL

func (s SqlServerOperator) ExecuteDDL(ctx context.Context, dbName, ddlStatement string) (err error)

func (SqlServerOperator) GetColumns

func (s SqlServerOperator) GetColumns(ctx context.Context, dbName string) (dbTableColMap map[string]map[string]*TableColInfo, err error)

func (SqlServerOperator) GetColumnsUnderTables

func (s SqlServerOperator) GetColumnsUnderTables(ctx context.Context, dbName, logicDBName string, tableNames []string) (tableColMap map[string]*TableColInfo, err error)

func (SqlServerOperator) GetDataBySQL

func (s SqlServerOperator) GetDataBySQL(ctx context.Context, dbName, sqlStatement string) (rows []map[string]interface{}, err error)

func (SqlServerOperator) GetTableData

func (s SqlServerOperator) GetTableData(ctx context.Context, dbName, schemaName, tableName string, pageInfo *Pagination) (rows []map[string]interface{}, err error)

func (SqlServerOperator) GetTablesUnderDB

func (s SqlServerOperator) GetTablesUnderDB(ctx context.Context, dbName string) (dbTableMap map[string]*LogicDBInfo, err error)

func (SqlServerOperator) Open

func (s SqlServerOperator) Open(config *gormx.Config) error

func (SqlServerOperator) Ping

func (s SqlServerOperator) Ping(dbName string) error

type TableColInfo

type TableColInfo struct {
	TableName      string
	ColumnInfoList []*ColumnInfo // 列
}

type TableInfo

type TableInfo struct {
	TableName string // 列名
	Comment   string // 注释
}

Jump to

Keyboard shortcuts

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