Skip to content

Commit

Permalink
Register the sqlite3 driver only once (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
subins2000 authored Dec 3, 2023
1 parent aa5022c commit 6856a92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ install.sh
govarnam.pc

*.vst
a
4 changes: 3 additions & 1 deletion govarnam/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ type Token struct {
character string // Non language character
}

var sqlite3WithLimitDriverRegistered bool
var sqlite3Conn *sqlite3.SQLiteConn

func openDB(path string) (*sql.DB, error) {
if sqlite3Conn == nil {
if !sqlite3WithLimitDriverRegistered {
sql.Register("sqlite3_with_limit", &sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
sqlite3Conn = conn
return nil
},
})
sqlite3WithLimitDriverRegistered = true
}

conn, err := sql.Open("sqlite3_with_limit", path)
Expand Down

0 comments on commit 6856a92

Please sign in to comment.