[add] tests, [add] refactor epub feat

This commit is contained in:
2023-10-23 20:18:16 -04:00
parent bf6ac96376
commit b5d5e4bd64
17 changed files with 429 additions and 353 deletions

View File

@@ -6,14 +6,9 @@ import (
_ "embed"
"fmt"
log "github.com/sirupsen/logrus"
_ "modernc.org/sqlite"
"path"
"reichard.io/bbank/config"
// CGO SQLite
// sqlite "github.com/mattn/go-sqlite3"
// GO SQLite
_ "modernc.org/sqlite"
)
type DBManager struct {
@@ -35,9 +30,12 @@ func NewMgr(c *config.Config) *DBManager {
}
// Create Database
if c.DBType == "sqlite" {
// GO SQLite
dbLocation := path.Join(c.ConfigPath, fmt.Sprintf("%s.db", c.DBName))
if c.DBType == "sqlite" || c.DBType == "memory" {
var dbLocation string = ":memory:"
if c.DBType == "sqlite" {
dbLocation = path.Join(c.ConfigPath, fmt.Sprintf("%s.db", c.DBName))
}
var err error
dbm.DB, err = sql.Open("sqlite", dbLocation)
if err != nil {
@@ -49,19 +47,6 @@ func NewMgr(c *config.Config) *DBManager {
if _, err := dbm.DB.Exec(ddl, nil); err != nil {
log.Info("Exec Error:", err)
}
// CGO SQLite
// sql.Register("sqlite3_custom", &sqlite.SQLiteDriver{
// ConnectHook: connectHookSQLite,
// })
// dbLocation := path.Join(c.ConfigPath, fmt.Sprintf("%s.db", c.DBName))
// var err error
// dbm.DB, err = sql.Open("sqlite3_custom", dbLocation)
// if err != nil {
// log.Fatal(err)
// }
} else {
log.Fatal("Unsupported Database")
}
@@ -77,15 +62,3 @@ func (dbm *DBManager) CacheTempTables() error {
}
return nil
}
/*
// CGO SQLite
func connectHookSQLite(conn *sqlite.SQLiteConn) error {
// Create Tables
log.Debug("Creating Schema")
if _, err := conn.Exec(ddl, nil); err != nil {
log.Warn("Create Schema Failure: ", err)
}
return nil
}
*/