Documentation ¶
Index ¶
Constants ¶
View Source
const DIALECT_DEFAULT_HOST = "127.0.0.1"
View Source
const FLASHDB_DEFAULT_PORT uint16 = 8000
View Source
const MYSQL_DEFAULT_PORT uint16 = 3306
View Source
const PGSQL_DEFAULT_PORT uint16 = 5432
View Source
const REDIS_DEFAULT_PORT uint16 = 6379
Variables ¶
View Source
var ( ConcatWith = utils.ConcatWith WrapWith = utils.WrapWith Escape = url.QueryEscape )
Functions ¶
func GetAccount ¶
Types ¶
type ConnConfig ¶
type ConnConfig struct { Type string `hcl:"type,label" json:"type"` Key string `hcl:"key,label" json:"key"` LogFile string `hcl:"log_file,optional" json:"log_file,omitempty"` Username string `hcl:"username,optional" json:"username,omitempty"` Password string `hcl:"password,optional" json:"password,omitempty"` DSN string `hcl:"dsn,optional" json:"dsn,omitempty"` Options url.Values `hcl:"options,optional" json:"options,omitempty"` Remain hcl.Body `hcl:",remain"` Dialect Dialect }
连接配置
func (ConnConfig) GetDSN ¶
func (c ConnConfig) GetDSN(full bool) string
func (*ConnConfig) LoadDialect ¶
func (c *ConnConfig) LoadDialect() Dialect
func (ConnConfig) Name ¶
func (c ConnConfig) Name() string
func (ConnConfig) QuickConnect ¶ added in v1.4.2
func (c ConnConfig) QuickConnect(verbose bool) *xorm.Engine
QuickConnect 连接数据库,需要先导入对应驱动
type Dialect ¶
type Dialect interface { Name() string ImporterPath() string IsXormDriver() bool QuoteIdent(ident string) string BuildDSN() string BuildFullDSN(username, password string) string }
func GetDialectByName ¶
type FlashDB ¶
type FlashDB struct { Path string `hcl:"path,optional" json:"path,omitempty"` EvictionInterval int `hcl:"eviction_interval,optional" json:"eviction_interval,omitempty"` }
func (FlashDB) BuildFullDSN ¶
func (FlashDB) ImporterPath ¶
func (FlashDB) IsXormDriver ¶ added in v1.4.2
func (FlashDB) QuoteIdent ¶
type Mysql ¶
type Mysql struct { Host string `hcl:"host" json:"host"` Port uint16 `hcl:"port,optional" json:"port,omitempty"` Database string `hcl:"database,optional" json:"database,omitempty"` }
func (Mysql) BuildFullDSN ¶
func (Mysql) ImporterPath ¶
func (Mysql) IsXormDriver ¶ added in v1.4.2
func (Mysql) QuoteIdent ¶
type Postgres ¶
type Postgres struct { Host string `hcl:"host" json:"host"` Port uint16 `hcl:"port,optional" json:"port,omitempty"` Database string `hcl:"database,optional" json:"database,omitempty"` }
func (Postgres) BuildFullDSN ¶
func (Postgres) ImporterPath ¶
func (Postgres) IsXormDriver ¶ added in v1.4.2
func (Postgres) QuoteIdent ¶
type Redis ¶
type Redis struct { Host string `hcl:"host" json:"host"` Port uint16 `hcl:"port,optional" json:"port,omitempty"` Database int `hcl:"database,optional" json:"database,omitempty"` }
func (Redis) BuildFullDSN ¶
func (Redis) ImporterPath ¶
func (Redis) IsXormDriver ¶ added in v1.4.2
func (Redis) QuoteIdent ¶
type Sqlite ¶
type Sqlite struct {
Path string `hcl:"path,optional" json:"path"`
}
func (Sqlite) BuildFullDSN ¶
func (Sqlite) ImporterPath ¶
func (Sqlite) IsXormDriver ¶ added in v1.4.2
func (Sqlite) QuoteIdent ¶
Click to show internal directories.
Click to hide internal directories.