gf/contrib/drivers/sqlite/sqlite.go

51 lines
1.2 KiB
Go
Raw Normal View History

// 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.
//
// Note:
// 1. It does not support Save features.
package sqlite
import (
2022-06-24 16:15:42 +08:00
_ "github.com/glebarez/go-sqlite"
"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 {
*gdb.Core
}
2023-02-14 09:45:29 +08:00
const (
quoteChar = "`"
)
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{}
}
// 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{
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
}