Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTableNames ¶
func ParseInsertFields(sql string) (string, error) {
// 正则表达式匹配 INSERT INTO 语句中的字段列表
re := regexp.MustCompile(`(?i)INSERT\s+INTO\s+\w+\s*\(([^)]+)\)`)
matches := re.FindStringSubmatch(sql)
if len(matches) < 2 {
return "", fmt.Errorf("无法找到插入字段列表")
}
return matches[1], nil
}
func ParseDestinationTable(sql string) (string, error) {
re := regexp.MustCompile(`(?i)INSERT\s+INTO\s+(\w+)`)
matches := re.FindStringSubmatch(sql)
if len(matches) < 2 {
return "", fmt.Errorf("无法找到目标表名")
}
return matches[1], nil
}
func ValidateIPPortFormat ¶
Types ¶
type HandleResult ¶
func (*HandleResult) HandleFailed ¶
func (handle *HandleResult) HandleFailed(msg string)
func (*HandleResult) HandleSuccess ¶
func (handle *HandleResult) HandleSuccess(code int32, msg string)
type IDbDriver ¶
type IDbDriver interface {
OpenConnect(connectJson string, maxIdleTime, maxOpenConnections, connMaxLifetime, maxIdleConnections int) error
CloseConnect() error
CheckSQLValid(strSQL, strFilterVal string) ([]tableInfo.ColumnInfo, error)
GetColumns(tableName string) ([]tableInfo.ColumnInfo, error)
GetTables() ([]tableInfo.TableInfo, error)
// PullData 从数据库中拉取数据,并写入到clickhouse中
PullData(strSQL, filterVal, destTable string, batch int, iTimestamp int64, clickClient *clickHouseLocal.TClickHouseDriver) (int64, error)
// PushData 从clickhouse中读取数据,并写入到数据库中
PushData(selectSQL, filterVal, destTable string, batch int, clickClient *clickHouseSQL.TClickHouseSQL) (int64, error) //作为函数参数
ConvertToClickHouseDDL(tableName string) (*string, error)
ConvertFromClickHouseDDL(tableName string, columns *[]tableInfo.ColumnInfo) (*string, error)
// GenerateInsertToClickHouseSQL columns 用户选择查询的字段列表,只含有字段名
GenerateInsertToClickHouseSQL(tableName string, myColumns *[]tableInfo.ColumnInfo, filterCol string) (*string, error)
// GenerateInsertFromClickHouseSQL columns 需要调用方处理用户选择的字段列表,并结合clickHouse获取的字段信息
GenerateInsertFromClickHouseSQL(tableName string, clickColumns *[]tableInfo.ColumnInfo, filterCol string) (*string, error)
GetQuoteFlag() string
GetSchema() string
IsConnected() bool
NewConnect(connectJson string, maxIdleTime, maxOpenConnections, connMaxLifetime, maxIdleConnections int) (IDbDriver, error)
}
Click to show internal directories.
Click to hide internal directories.