db

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DatabaseTypes []*DatabaseType
)
View Source
var (
	FileUploadDir string
)
View Source
var (
	SqlConditionalOperations []*SqlConditionalOperation
)

Functions

This section is empty.

Types

type Config added in v0.0.7

type Config struct {
	Type            string `json:"type,omitempty"`
	Host            string `json:"host,omitempty"`
	Port            int    `json:"port,omitempty"`
	Database        string `json:"database,omitempty"`
	DbName          string `json:"dbName,omitempty"`
	Username        string `json:"username,omitempty"`
	Password        string `json:"password,omitempty"`
	OdbcDsn         string `json:"odbcDsn,omitempty"`
	OdbcDialectName string `json:"odbcDialectName,omitempty"`

	Schema       string `json:"schema,omitempty"`
	Sid          string `json:"sid,omitempty"`
	MaxIdleConn  int    `json:"maxIdleConn,omitempty"`
	MaxOpenConn  int    `json:"maxOpenConn,omitempty"`
	DatabasePath string `json:"databasePath,omitempty"`
}

type DataListResult added in v0.0.7

type DataListResult struct {
	Sql      string                   `json:"sql"`
	Total    int                      `json:"total"`
	Args     []interface{}            `json:"args"`
	DataList []map[string]interface{} `json:"dataList"`
}

type DatabaseType added in v0.0.7

type DatabaseType struct {
	DialectName string `json:"dialectName"`
	// contains filtered or unexported fields
}

func GetDatabaseType added in v0.0.7

func GetDatabaseType(databaseType string) *DatabaseType

type IService

type IService interface {
	Stop()
	GetDialectName() string
	Exec(sql string, args []interface{}) (rowsAffected int64, err error)
	Execs(sqlList []string, argsList [][]interface{}) (rowsAffected int64, err error)
	Count(sql string, args []interface{}) (count int64, err error)
	QueryOne(sql string, args []interface{}, one interface{}) (find bool, err error)
	Query(sql string, args []interface{}, list interface{}) (err error)
	QueryMap(sql string, args []interface{}) (list []map[string]interface{}, err error)
	QueryPage(sql string, args []interface{}, list interface{}, page *worker.Page) (err error)
	QueryMapPage(sql string, args []interface{}, page *worker.Page) (list []map[string]interface{}, err error)
	Info() (res interface{}, err error)
	OwnerCreateSql(param *Param, owner *dialect.OwnerModel) (sqlList []string, err error)
	OwnersSelect(param *Param) (owners []*dialect.OwnerModel, err error)
	TablesSelect(param *Param, ownerName string) (tables []*dialect.TableModel, err error)
	TableDetail(param *Param, ownerName string, tableName string) (tableDetail *dialect.TableModel, err error)
	OwnerCreate(param *Param, owner *dialect.OwnerModel) (created bool, err error)
	OwnerDelete(param *Param, ownerName string) (deleted bool, err error)
	OwnerDataTrim(param *Param, ownerName string) (err error)
	DDL(param *Param, ownerName string, tableName string) (sqlList []string, err error)
	Model(param *Param, ownerName string, tableName string) (content string, err error)
	TableCreate(param *Param, ownerName string, table *dialect.TableModel) (err error)
	TableDelete(param *Param, ownerName string, tableName string) (err error)
	TableDataTrim(param *Param, ownerName string, tableName string) (err error)
	TableCreateSql(param *Param, ownerName string, table *dialect.TableModel) (sqlList []string, err error)
	TableUpdateSql(param *Param, ownerName string, tableName string, updateTableParam *UpdateTableParam) (sqlList []string, err error)
	TableUpdate(param *Param, ownerName string, tableName string, updateTableParam *UpdateTableParam) (err error)
	DataListSql(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel,
		insertDataList []map[string]interface{},
		updateDataList []map[string]interface{}, updateWhereDataList []map[string]interface{},
		deleteDataList []map[string]interface{},
	) (sqlList []string, err error)
	DataListExec(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel,
		insertDataList []map[string]interface{},
		updateDataList []map[string]interface{}, updateWhereDataList []map[string]interface{},
		deleteDataList []map[string]interface{},
	) (err error)

	TableData(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel, whereList []*dialect.Where, orderList []*dialect.Order, pageSize int, pageNo int) (dataListResult DataListResult, err error)
	GetTargetDialect(param *Param) (dia dialect.Dialect)
	ExecuteSQL(param *Param, ownerName string, sqlContent string) (executeList []map[string]interface{}, errStr string, err error)
	StartExport(param *Param, exportParam *worker.TaskExportParam) (task *worker.Task, err error)
	StartImport(param *Param, importParam *worker.TaskImportParam) (task *worker.Task, err error)
	StartSync(param *Param, syncParam *worker.TaskSyncParam) (task *worker.Task, err error)
}

func New added in v0.0.7

func New(config Config) (IService, error)

New 创建 db客户端

type Param added in v0.0.7

type Param struct {
	*dialect.ParamModel
	TargetDatabaseType   string  `json:"targetDatabaseType"`
	AppendOwnerCreateSql bool    `json:"appendOwnerCreateSql"`
	AppendOwnerName      bool    `json:"appendOwnerName"`
	OpenTransaction      bool    `json:"openTransaction"`
	ErrorContinue        bool    `json:"errorContinue"`
	ExecUsername         string  `json:"execUsername"`
	ExecPassword         string  `json:"execPassword"`
	ExportType           string  `json:"exportType"`
	ImportType           string  `json:"importType"`
	TargetDatabaseConfig *Config `json:"targetDatabaseConfig"`
	ModelType            string  `json:"modelType"`

	FormatIndexName bool `json:"formatIndexName"`
}

type Service added in v0.0.7

type Service struct {
	dialect.Dialect
	// contains filtered or unexported fields
}

Service 注册处理器在线信息等

func (*Service) Count added in v0.0.7

func (this_ *Service) Count(sql string, args []interface{}) (count int64, err error)

func (*Service) DDL added in v0.0.7

func (this_ *Service) DDL(param *Param, ownerName string, tableName string) (sqlList []string, err error)

func (*Service) DataListExec added in v0.0.7

func (this_ *Service) DataListExec(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel,
	insertDataList []map[string]interface{},
	updateDataList []map[string]interface{}, updateWhereDataList []map[string]interface{},
	deleteDataList []map[string]interface{},
) (err error)

func (*Service) DataListSql added in v0.0.7

func (this_ *Service) DataListSql(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel,
	insertDataList []map[string]interface{},
	updateDataList []map[string]interface{}, updateWhereDataList []map[string]interface{},
	deleteDataList []map[string]interface{},
) (sqlList []string, err error)

func (*Service) Exec added in v0.0.7

func (this_ *Service) Exec(sql string, args []interface{}) (rowsAffected int64, err error)

func (*Service) Execs added in v0.0.7

func (this_ *Service) Execs(sqlList []string, argsList [][]interface{}) (rowsAffected int64, err error)

func (*Service) ExecuteSQL added in v0.0.7

func (this_ *Service) ExecuteSQL(param *Param, ownerName string, sqlContent string) (executeList []map[string]interface{}, errStr string, err error)

func (*Service) GetConfig added in v0.0.7

func (this_ *Service) GetConfig() (config *Config)

func (*Service) GetDialectName added in v0.0.7

func (this_ *Service) GetDialectName() string

func (*Service) GetTargetDialect added in v0.0.7

func (this_ *Service) GetTargetDialect(param *Param) (dia dialect.Dialect)

func (*Service) Info added in v0.0.7

func (this_ *Service) Info() (res interface{}, err error)

func (*Service) Model added in v0.0.7

func (this_ *Service) Model(param *Param, ownerName string, tableName string) (content string, err error)

func (*Service) Open added in v0.0.7

func (this_ *Service) Open() (err error)

func (*Service) OwnerCreate added in v0.0.7

func (this_ *Service) OwnerCreate(param *Param, owner *dialect.OwnerModel) (created bool, err error)

func (*Service) OwnerCreateSql added in v0.1.1

func (this_ *Service) OwnerCreateSql(param *Param, owner *dialect.OwnerModel) (sqlList []string, err error)

func (*Service) OwnerDataTrim added in v0.0.7

func (this_ *Service) OwnerDataTrim(param *Param, ownerName string) (err error)

func (*Service) OwnerDelete added in v0.0.7

func (this_ *Service) OwnerDelete(param *Param, ownerName string) (deleted bool, err error)

func (*Service) OwnersSelect added in v0.0.7

func (this_ *Service) OwnersSelect(param *Param) (owners []*dialect.OwnerModel, err error)

func (*Service) Query added in v0.0.7

func (this_ *Service) Query(sql string, args []interface{}, list interface{}) (err error)

func (*Service) QueryMap added in v0.0.7

func (this_ *Service) QueryMap(sql string, args []interface{}) (list []map[string]interface{}, err error)

func (*Service) QueryMapPage added in v0.0.7

func (this_ *Service) QueryMapPage(sql string, args []interface{}, page *worker.Page) (list []map[string]interface{}, err error)

func (*Service) QueryOne added in v0.0.7

func (this_ *Service) QueryOne(sql string, args []interface{}, one interface{}) (find bool, err error)

func (*Service) QueryPage added in v0.0.7

func (this_ *Service) QueryPage(sql string, args []interface{}, list interface{}, page *worker.Page) (err error)

func (*Service) StartExport added in v0.0.7

func (this_ *Service) StartExport(param *Param, exportParam *worker.TaskExportParam) (task *worker.Task, err error)

func (*Service) StartImport added in v0.0.7

func (this_ *Service) StartImport(param *Param, importParam *worker.TaskImportParam) (task *worker.Task, err error)

func (*Service) StartSync added in v0.0.7

func (this_ *Service) StartSync(param *Param, syncParam *worker.TaskSyncParam) (task *worker.Task, err error)

func (*Service) Stop added in v0.0.7

func (this_ *Service) Stop()

func (*Service) TableCreate added in v0.0.7

func (this_ *Service) TableCreate(param *Param, ownerName string, table *dialect.TableModel) (err error)

func (*Service) TableCreateSql added in v0.0.7

func (this_ *Service) TableCreateSql(param *Param, ownerName string, table *dialect.TableModel) (sqlList []string, err error)

func (*Service) TableData added in v0.0.7

func (this_ *Service) TableData(param *Param, ownerName string, tableName string, columnList []*dialect.ColumnModel, whereList []*dialect.Where, orderList []*dialect.Order, pageSize int, pageNo int) (dataListResult DataListResult, err error)

func (*Service) TableDataTrim added in v0.0.7

func (this_ *Service) TableDataTrim(param *Param, ownerName string, tableName string) (err error)

func (*Service) TableDelete added in v0.0.7

func (this_ *Service) TableDelete(param *Param, ownerName string, tableName string) (err error)

func (*Service) TableDetail added in v0.0.7

func (this_ *Service) TableDetail(param *Param, ownerName string, tableName string) (tableDetail *dialect.TableModel, err error)

func (*Service) TableUpdate added in v0.0.7

func (this_ *Service) TableUpdate(param *Param, ownerName string, tableName string, updateTableParam *UpdateTableParam) (err error)

func (*Service) TableUpdateSql added in v0.0.7

func (this_ *Service) TableUpdateSql(param *Param, ownerName string, tableName string, updateTableParam *UpdateTableParam) (sqlList []string, err error)

func (*Service) TablesSelect added in v0.0.7

func (this_ *Service) TablesSelect(param *Param, ownerName string) (tables []*dialect.TableModel, err error)

type SqlConditionalOperation added in v0.1.1

type SqlConditionalOperation struct {
	Value string `json:"value,omitempty"`
	Text  string `json:"text,omitempty"`
}

func GetSqlConditionalOperations added in v0.1.1

func GetSqlConditionalOperations() []*SqlConditionalOperation

type UpdateTableColumn added in v0.0.7

type UpdateTableColumn struct {
	*dialect.ColumnModel
	OldColumn *dialect.ColumnModel `json:"oldColumn"`
	Deleted   bool                 `json:"deleted"`
}

type UpdateTableIndex added in v0.0.7

type UpdateTableIndex struct {
	*dialect.IndexModel
	OldIndex *dialect.IndexModel `json:"oldIndex"`
	Deleted  bool                `json:"deleted"`
}

type UpdateTableParam added in v0.0.7

type UpdateTableParam struct {
	TableComment    string               `json:"tableComment"`
	OldTableComment string               `json:"oldTableComment"`
	ColumnList      []*UpdateTableColumn `json:"columnList"`
	IndexList       []*UpdateTableIndex  `json:"indexList"`
}

Jump to

Keyboard shortcuts

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