1
0
mirror of https://github.com/xiaoqidun/entps synced 2025-04-04 20:47:53 +08:00

feat(初始项目): 初始项目

This commit is contained in:
2021-08-11 11:43:19 +08:00
parent 7a013be381
commit f80c9c8f60
5 changed files with 116 additions and 1 deletions

31
entps.go Normal file
View File

@ -0,0 +1,31 @@
package entps
import (
"database/sql"
"database/sql/driver"
"modernc.org/sqlite"
)
type sqlite3Driver struct {
*sqlite.Driver
}
type sqlite3DriverConn interface {
Exec(string, []driver.Value) (driver.Result, error)
}
func (d sqlite3Driver) Open(name string) (conn driver.Conn, err error) {
conn, err = d.Driver.Open(name)
if err != nil {
return
}
_, err = conn.(sqlite3DriverConn).Exec("PRAGMA foreign_keys = ON;", nil)
if err != nil {
_ = conn.Close()
}
return
}
func init() {
sql.Register("sqlite3", sqlite3Driver{Driver: &sqlite.Driver{}})
}