2022-01-24 14:41:23 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
|
|
//
|
|
|
|
// 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.
|
2022-09-26 22:11:13 +08:00
|
|
|
|
|
|
|
// Package sqlite implements gdb.Driver, which supports operations for database SQLite.
|
2022-01-24 14:41:23 +08:00
|
|
|
//
|
|
|
|
// Note:
|
2023-09-04 21:23:54 +08:00
|
|
|
// 1. It does not support Save features.
|
2022-01-24 14:41:23 +08:00
|
|
|
package sqlite
|
|
|
|
|
|
|
|
import (
|
2022-06-24 16:15:42 +08:00
|
|
|
_ "github.com/glebarez/go-sqlite"
|
2023-07-25 20:45:34 +08:00
|
|
|
|
2022-01-24 14:41:23 +08:00
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
|
|
)
|
|
|
|
|
2022-02-15 23:43:47 +08:00
|
|
|
// Driver is the driver for sqlite database.
|
|
|
|
type Driver struct {
|
2022-01-24 14:41:23 +08:00
|
|
|
*gdb.Core
|
|
|
|
}
|
|
|
|
|
2023-02-14 09:45:29 +08:00
|
|
|
const (
|
|
|
|
quoteChar = "`"
|
|
|
|
)
|
|
|
|
|
2022-01-24 14:41:23 +08:00
|
|
|
func init() {
|
|
|
|
if err := gdb.Register(`sqlite`, New()); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// New create and returns a driver that implements gdb.Driver, which supports operations for SQLite.
|
|
|
|
func New() gdb.Driver {
|
2022-02-15 23:43:47 +08:00
|
|
|
return &Driver{}
|
2022-01-24 14:41:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// New creates and returns a database object for sqlite.
|
|
|
|
// It implements the interface of gdb.Driver for extra database driver installation.
|
2022-02-15 23:43:47 +08:00
|
|
|
func (d *Driver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error) {
|
|
|
|
return &Driver{
|
2022-01-24 14:41:23 +08:00
|
|
|
Core: core,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetChars returns the security char for this type of database.
|
2022-02-15 23:43:47 +08:00
|
|
|
func (d *Driver) GetChars() (charLeft string, charRight string) {
|
2023-02-14 09:45:29 +08:00
|
|
|
return quoteChar, quoteChar
|
2022-01-24 14:41:23 +08:00
|
|
|
}
|