Files
gf/database/gdb/gdb_sqlite.go

54 lines
1.3 KiB
Go
Raw Normal View History

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2018-08-08 09:09:28 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
2020-01-06 20:43:59 +08:00
//
// Note:
// 1. It needs manually import: _ "github.com/mattn/go-sqlite3"
// 2. It does not support Save/Replace features.
2018-08-08 09:09:28 +08:00
package gdb
import (
"database/sql"
)
2018-12-14 18:35:51 +08:00
type dbSqlite struct {
*dbBase
2018-08-08 09:09:28 +08:00
}
func (db *dbSqlite) Open(config *ConfigNode) (*sql.DB, error) {
2018-08-08 09:09:28 +08:00
var source string
if config.LinkInfo != "" {
source = config.LinkInfo
2018-08-08 09:09:28 +08:00
} else {
source = config.Name
2018-08-08 09:09:28 +08:00
}
if db, err := sql.Open("sqlite3", source); err == nil {
return db, nil
} else {
return nil, err
}
}
2019-06-19 09:06:52 +08:00
func (db *dbSqlite) getChars() (charLeft string, charRight string) {
2018-12-14 18:35:51 +08:00
return "`", "`"
2018-08-08 09:09:28 +08:00
}
// TODO
2020-01-07 22:14:32 +08:00
func (db *dbSqlite) Tables(schema ...string) (tables []string, err error) {
return
}
// TODO
2020-01-07 22:14:32 +08:00
func (db *dbSqlite) TableFields(table string, schema ...string) (fields map[string]*TableField, err error) {
return
}
// @todo 需要增加对Save方法的支持可使用正则来实现替换
// @todo 将ON DUPLICATE KEY UPDATE触发器修改为两条SQL语句(INSERT OR IGNORE & UPDATE)
2020-01-07 22:14:32 +08:00
func (db *dbSqlite) handleSqlBeforeExec(sql string) string {
return sql
2019-06-19 09:06:52 +08:00
}