mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-20 03:47:24 +08:00
* frontend * fixed Database.DBx return value * api endpoint * updated swagger * fix openbsd variable dereference * tests * only load information if user is owner * memory improvement for other routes
25 lines
578 B
Go
25 lines
578 B
Go
//go:build linux || windows || darwin
|
|
// +build linux windows darwin
|
|
|
|
package database
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/pkg/errors"
|
|
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
// OpenSQLiteDatabase creates and open connection to new SQLite3 database.
|
|
func OpenSQLiteDatabase(ctx context.Context, databasePath string) (sqliteDB *SQLiteDatabase, err error) {
|
|
// Open database
|
|
db, err := sqlx.ConnectContext(ctx, "sqlite", databasePath)
|
|
if err != nil {
|
|
return nil, errors.WithStack(err)
|
|
}
|
|
|
|
sqliteDB = &SQLiteDatabase{dbbase: dbbase{db}}
|
|
return sqliteDB, nil
|
|
}
|