Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(conConfig ConnectConfig) (*sql.DB, error)
- func ExportMySqlCSV(conConfig ConnectConfig, pathMySql string, tableName string, csvFile string) error
- func ExportPostgreCSV(conConfig ConnectConfig, pathPsql string, tableName string, csvFile string) error
- func Retreive(db *sql.DB, tableName string, sql string) ([]map[string]interface{}, error)
- func RunCommandMysql(conConfig ConnectConfig, pathMySql string, sql string) error
- type ColumnInfo
- type ConnectConfig
- type DefineConfigOneFileMultiDefine
- type DefineConfigOneFileOneDefine
- type DefineDetail
- type DefineIn
- type JsonItemInfo
- type PostgreConfig
- type TableDefine
Constants ¶
View Source
const ( // 连接字符串(PostgreSQL) CON_STRING_POSTGRE = "host=%s port=%s user=%s password=%s dbname=%s sslmode=disable" // 连接字符串(MySql) // "用户名:密码@[连接方式](主机名:端口号)/数据库名" CON_STRING_MYSQL = "%s:%s@%s(%s:%s)/%s" // 连接字符串(Oracle) // "用户名/密码@主机名:端口号/数据库名" CON_STRING_ORACLE = "%s/%s@%s:%s/%s" // 数据库类型 DB_TYPE_POSTGRE string = "1" // PostgreSQL DB_TYPE_MYSQL string = "2" // MySQL DB_TYPE_ORACLE string = "3" // Oracle DB_TYPE_SQLSERVER string = "4" // SqlServer DB_TYPE_SQLITE string = "5" // Sqlites // 表替换用占位符 PLACEHOLDER_TABLE = "#TABLE#" // 导出全部数据用SQL DEFALT_SQL = " select * from " + PLACEHOLDER_TABLE + " " )
View Source
const DEFINE_SHEET_INDEX_NONE int = 0
表定义配置文件 工作表下标(不使用下标的场合,值设置为0)
View Source
const DEFINE_TYPE_ONE_FILE_MULTI_DEFINE string = "2"
View Source
const DEFINE_TYPE_ONE_FILE_ONE_DEFINE string = "1"
/ 表定义种类常量
Variables ¶
View Source
var S_BOOL = []string{"bool", "boolean"}
View Source
var S_DATE_TIME = []string{"date", "time"}
View Source
var S_JSON = []string{"json", "jsonb"}
View Source
var S_NUMBER = []string{"integer", "number", "int"}
View Source
var S_TEXT = []string{"char", "varchar", "varchar2", "text"}
View Source
var S_YES = []string{"○", "〇", "Y"}
Functions ¶
func ExportMySqlCSV ¶
func ExportMySqlCSV(conConfig ConnectConfig, pathMySql string, tableName string, csvFile string) error
导出CSV my.ini文件的secure-file-priv需要设置成空字符串 secure-file-priv=""
func ExportPostgreCSV ¶
func ExportPostgreCSV(conConfig ConnectConfig, pathPsql string, tableName string, csvFile string) error
导出CSV
func RunCommandMysql ¶
func RunCommandMysql(conConfig ConnectConfig, pathMySql string, sql string) error
mysql.exe 执行sql
Types ¶
type ColumnInfo ¶
type ColumnInfo struct { No string ColumnLogicalName string ColumnName string Type string JsonItem []JsonItemInfo Length int LengthEx int PK bool NotNull bool Default string Description string Remark string IsJson bool Data string }
列
type ConnectConfig ¶
type ConnectConfig struct { // 数据库类型 DbType string `yaml:"dbType"` Host string `yaml:"host"` // 数据库服务器名或IP Port string `yaml:"port"` // 端口 Network string `yaml:"network"` // 连接方式 User string `yaml:"user"` // 用户名 Password string `yaml:"password"` // 密码 Schema string `yaml:"schema"` // 数据库名(Schema) }
func ReadConnectConfig ¶
func ReadConnectConfig(configFile string) (conConfig ConnectConfig, err error)
读取数据库配置
type DefineConfigOneFileMultiDefine ¶
type DefineConfigOneFileMultiDefine struct { DefineSheetNamePart []string `yaml:"defineSheetNamePart"` ExcludeSheetNamePart []string `yaml:"excludeSheetNamePart"` Detail DefineDetail `yaml:"detail"` }
表定义配置
type DefineConfigOneFileOneDefine ¶
type DefineConfigOneFileOneDefine struct { DefineSheetIndex int `yaml:"defineSheetIndex"` DefineSheetNamePart []string `yaml:"defineSheetNamePart"` Detail DefineDetail `yaml:"detail"` }
表定义配置
type DefineDetail ¶
type DefineDetail struct { CellTableLogicalName string `yaml:"cellTableLogicalName"` CellTableName string `yaml:"cellTableName"` ColNo string `yaml:"colNo"` ColColumnLogicalName string `yaml:"colColumnLogicalName"` ColColumnName string `yaml:"colColumnName"` ColPK string `yaml:"colPK"` ColType string `yaml:"colType"` ColLength string `yaml:"colLength"` ColNotNull string `yaml:"colNotNull"` ColDefault string `yaml:"colDefault"` ColDescription string `yaml:"colDescription"` ColRemark string `yaml:"colRemark"` StartRow int `yaml:"startRow"` LastRow int // JSON(JSONB)项目 ColItemLogicalName string `yaml:"colItemLogicalName"` ColItemName string `yaml:"colItemName"` ColItemType string `yaml:"colItemType"` ColItemLength string `yaml:"colItemLength"` }
type DefineIn ¶
type DefineIn struct { // 表设计文件种类 DefineType []string `yaml:"defineType"` // 表设计文件 DefineFile []string `yaml:"defineFile"` // 表定义配置文件 DefineConfigOneFileOneDefine string `yaml:"defineConfigOneFileOneDefine"` DefineConfigOneFileMultiDefine string `yaml:"defineConfigOneFileMultiDefine"` DefineConfigOneSheetMultiDefine string `yaml:"defineConfigOneSheetMultiDefine"` // 表设计文件(XLSX) DefineContentFile string `yaml:"defineContentFile"` }
表定义输入
type JsonItemInfo ¶
type JsonItemInfo struct { ItemNo string ItemLogicalName string ItemName string ItemType string ItemLength int ItemLengthEx int }
JSON(JSONB)项目
type PostgreConfig ¶
type PostgreConfig struct { // PostgreSQL psql.exe全路径 PathPsql string `yaml:"pathPsql"` }
Postgre配置
func ReadPostgreConfig ¶
func ReadPostgreConfig(configFile string) (postgreConfig PostgreConfig, err error)
读取Postgre相关配置
type TableDefine ¶
type TableDefine struct { TableLogicalName string TableName string Column []ColumnInfo ExInfo string HasJsonColumn bool }
表
func GetTableDefine ¶
func GetTableDefine(defInFile string) (tableDefine []TableDefine, err error)
获取表定义
Click to show internal directories.
Click to hide internal directories.