schema

package
v0.6.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IsNotKey   IndexKeyType = ""    // 普通字段
	IndexKey                = "MUL" // 普通索引
	UniqueKey               = "UNI" // 唯一索引
	PrimaryKey              = "PRI" // 主键
)

索引类型

View Source
const MSSQL_DEFAULT_PORT uint16 = 1433
View Source
const MYSQL_DEFAULT_PORT uint16 = 3306
View Source
const ORACLE_DEFAULT_PORT uint16 = 1521
View Source
const PGSQL_DEFAULT_PORT uint16 = 5432

Variables

View Source
var DefaultColumnExtra = ColumnExtra{DefaultValue: sql.NullString{}}

Functions

func ColumnDefaultValue

func ColumnDefaultValue(typeName string) string

Types

type ColumnExtra

type ColumnExtra struct {
	FieldName           string
	FullType            string
	IndexType           IndexKeyType
	DefaultValue        sql.NullString
	MaxSize             int
	PrecSize, PrecScale int
	Extra               string
	Comment             string
}

type ColumnInfo

type ColumnInfo struct {
	Table *TableInfo
	*sql.ColumnType
	ColumnExtra
}

func (*ColumnInfo) GetDbType

func (ci *ColumnInfo) GetDbType() string

func (*ColumnInfo) GetDefault

func (ci *ColumnInfo) GetDefault() string

func (*ColumnInfo) GetDefine

func (ci *ColumnInfo) GetDefine() string

func (*ColumnInfo) GetPrecision

func (ci *ColumnInfo) GetPrecision() (int, int)

func (*ColumnInfo) GetSize

func (ci *ColumnInfo) GetSize() int

func (*ColumnInfo) IsIndex

func (ci *ColumnInfo) IsIndex() bool

func (*ColumnInfo) IsNotNull

func (ci *ColumnInfo) IsNotNull() bool

func (*ColumnInfo) IsPrimaryKey

func (ci *ColumnInfo) IsPrimaryKey() bool

type Dialect

type Dialect interface {
	GetDSN(params redisw.ConnParams) (string, string)
	QuoteIdent(ident string) string
	CurrDbNameSql() string
	TableNameSql(dbname string, more bool) string
	ViewNameSql(dbname string, more bool) string
	ColumnTypeSql(fullTableName string) string
	ColumnInfoSql(table, dbname string) string
}

func GetDialect

func GetDialect(db *sql.DB) (Dialect, string, error)

func GetDialectByName

func GetDialectByName(name string) Dialect

type FetchFunc

type FetchFunc = func(rows *sql.Rows) (err error)

type IndexKeyType

type IndexKeyType string

type Mssql

type Mssql struct {
}

func (Mssql) ColumnInfoSql

func (d Mssql) ColumnInfoSql(table, dbname string) string

func (Mssql) ColumnTypeSql

func (Mssql) ColumnTypeSql(fullTableName string) string

func (Mssql) CurrDbNameSql

func (d Mssql) CurrDbNameSql() string

func (Mssql) GetDSN

func (Mssql) GetDSN(params redisw.ConnParams) (string, string)

func (Mssql) QuoteIdent

func (Mssql) QuoteIdent(ident string) string

func (Mssql) TableNameSql

func (d Mssql) TableNameSql(dbname string, more bool) string

func (Mssql) ViewNameSql

func (d Mssql) ViewNameSql(dbname string, more bool) string

type Mysql

type Mysql struct {
}

func (Mysql) ColumnInfoSql

func (d Mysql) ColumnInfoSql(table, dbname string) string

func (Mysql) ColumnTypeSql

func (Mysql) ColumnTypeSql(fullTableName string) string

func (Mysql) CurrDbNameSql

func (d Mysql) CurrDbNameSql() string

func (Mysql) GetDSN

func (Mysql) GetDSN(params redisw.ConnParams) (string, string)

func (Mysql) QuoteIdent

func (Mysql) QuoteIdent(ident string) string

func (Mysql) TableNameSql

func (d Mysql) TableNameSql(dbname string, more bool) string

func (Mysql) ViewNameSql

func (d Mysql) ViewNameSql(dbname string, more bool) string

type Oracle

type Oracle struct {
}

func (Oracle) ColumnInfoSql

func (d Oracle) ColumnInfoSql(table, dbname string) string

func (Oracle) ColumnTypeSql

func (Oracle) ColumnTypeSql(fullTableName string) string

func (Oracle) CurrDbNameSql

func (Oracle) CurrDbNameSql() string

func (Oracle) GetDSN

func (Oracle) GetDSN(params redisw.ConnParams) (string, string)

func (Oracle) QuoteIdent

func (Oracle) QuoteIdent(ident string) string

func (Oracle) TableNameSql

func (d Oracle) TableNameSql(dbname string, more bool) string

func (Oracle) ViewNameSql

func (d Oracle) ViewNameSql(dbname string, more bool) string

type Postgres

type Postgres struct {
}

func (Postgres) ColumnInfoSql

func (d Postgres) ColumnInfoSql(table, dbname string) string

func (Postgres) ColumnTypeSql

func (Postgres) ColumnTypeSql(fullTableName string) string

func (Postgres) CurrDbNameSql

func (d Postgres) CurrDbNameSql() string

func (Postgres) GetDSN

func (Postgres) GetDSN(params redisw.ConnParams) (string, string)

func (Postgres) QuoteIdent

func (Postgres) QuoteIdent(ident string) string

func (Postgres) TableNameSql

func (d Postgres) TableNameSql(dbname string, more bool) string

func (Postgres) ViewNameSql

func (d Postgres) ViewNameSql(dbname string, more bool) string

type Schema

type Schema struct {
	DriverName string
	Dialect    Dialect
	Error      error
	// contains filtered or unexported fields
}

func NewSchema

func NewSchema(db *sql.DB) *Schema

func (*Schema) AllTableInfos

func (s *Schema) AllTableInfos(dbname string, more bool) map[string]TableInfo

func (*Schema) GetColumnExtras

func (s *Schema) GetColumnExtras(table, dbname string) map[string]ColumnExtra

func (*Schema) GetColumnInfos

func (s *Schema) GetColumnInfos(table, dbname string) []*ColumnInfo

func (*Schema) GetColumnTypes

func (s *Schema) GetColumnTypes(fullTableName string) (cols []*sql.ColumnType)

func (*Schema) GetCurrDbName

func (s *Schema) GetCurrDbName() (dbname string)

func (*Schema) GetString

func (s *Schema) GetString(dsql string, offset int) (name string)

func (*Schema) GetStrings

func (s *Schema) GetStrings(dsql string) (names []string)

func (*Schema) GetTableInfo

func (s *Schema) GetTableInfo(table, dbname string) (tbInfo TableInfo)

func (*Schema) GetTableNames

func (s *Schema) GetTableNames(dbname string) (names []string)

func (*Schema) GetViewNames

func (s *Schema) GetViewNames(dbname string) (names []string)

func (*Schema) ListTable added in v0.5.0

func (s *Schema) ListTable(dbname string, refresh bool) (tables map[string]TableInfo)

func (*Schema) Query

func (s *Schema) Query(fetch FetchFunc, dsql string, args ...interface{}) error

type Sqlite

type Sqlite struct {
}

func (Sqlite) ColumnInfoSql

func (d Sqlite) ColumnInfoSql(table, dbname string) string

func (Sqlite) ColumnTypeSql

func (Sqlite) ColumnTypeSql(fullTableName string) string

func (Sqlite) CurrDbNameSql

func (Sqlite) CurrDbNameSql() string

func (Sqlite) GetDSN

func (Sqlite) GetDSN(params redisw.ConnParams) (string, string)

func (Sqlite) QuoteIdent

func (Sqlite) QuoteIdent(ident string) string

func (Sqlite) TableNameSql

func (d Sqlite) TableNameSql(dbname string, more bool) string

func (Sqlite) ViewNameSql

func (d Sqlite) ViewNameSql(dbname string, more bool) string

type TableInfo

type TableInfo struct {
	DbName       string
	TablePrefix  string
	TableName    string
	TableComment string
	TableRows    int64
	Quote        func(ident string) string
}

表名信息

func (TableInfo) GetFullName

func (ti TableInfo) GetFullName(escape bool) string

type UnknownDriverError

type UnknownDriverError struct {
	Driver string
}

func (UnknownDriverError) Error

func (e UnknownDriverError) Error() string

Jump to

Keyboard shortcuts

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