Tested sqlite db
This commit is contained in:
parent
b84bfa563c
commit
b0219e9052
|
@ -8,3 +8,4 @@ frontend/npm-debug.log*
|
|||
frontend/yarn-debug.log*
|
||||
frontend/yarn-error.log*
|
||||
config.ini
|
||||
db.db
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
//_ "github.com/mattn/go-sqlite3" // Because.
|
||||
_ "github.com/go-sql-driver/mysql" // Because.
|
||||
"github.com/go-xorm/core"
|
||||
"github.com/go-xorm/xorm"
|
||||
|
@ -13,6 +14,7 @@ func getEngine() (*xorm.Engine, error) {
|
|||
connStr := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=true",
|
||||
Config.Database.User, Config.Database.Password, Config.Database.Host, Config.Database.Database)
|
||||
return xorm.NewEngine("mysql", connStr)
|
||||
//return xorm.NewEngine("sqlite3", "./db.db")
|
||||
}
|
||||
|
||||
// SetEngine sets the xorm.Engine
|
||||
|
@ -22,6 +24,11 @@ func SetEngine() (err error) {
|
|||
return fmt.Errorf("Failed to connect to database: %v", err)
|
||||
}
|
||||
|
||||
// Cache
|
||||
cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
|
||||
x.SetDefaultCacher(cacher)
|
||||
|
||||
|
||||
x.SetMapper(core.GonicMapper{})
|
||||
|
||||
// Sync dat shit
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"git.mowie.cc/konrad/Library/models"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BookList is the handler to list books
|
||||
|
@ -16,6 +17,7 @@ func BookList(c echo.Context) error {
|
|||
list, err := models.ListBooks(search)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting books"})
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,6 @@
|
|||
"path": "github.com/go-ini/iniv1.28.2",
|
||||
"revision": ""
|
||||
},
|
||||
{
|
||||
"path": "github.com/go-sql-driver/go-sqlite3",
|
||||
"revision": ""
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "fSlTr0rwLji0DfsUOKYLkGUkiWo=",
|
||||
"path": "github.com/go-sql-driver/mysql",
|
||||
|
|
Loading…
Reference in New Issue