mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
init project
This commit is contained in:
31
store/sqlite.go
Normal file
31
store/sqlite.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
var DB *sql.DB
|
||||
|
||||
func InitDBConn() {
|
||||
db, err := sql.Open("sqlite3", "./resources/memos.db")
|
||||
if err != nil {
|
||||
fmt.Println("connect failed")
|
||||
} else {
|
||||
DB = db
|
||||
fmt.Println("connect to sqlite succeed")
|
||||
}
|
||||
}
|
||||
|
||||
func FormatDBError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch err.Error() {
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user