Initial sqlite3 compatibility
This commit is contained in:
9
app.go
9
app.go
@@ -4,7 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"flag"
|
||||
"fmt"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -258,7 +258,12 @@ func Serve() {
|
||||
|
||||
func connectToDatabase(app *app) {
|
||||
log.Info("Connecting to database...")
|
||||
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database))
|
||||
|
||||
if app.cfg.Database.Type != "sqlite3" {
|
||||
log.Error("This fork of writefreely only supports sqlite3 databases")
|
||||
os.Exit(1)
|
||||
}
|
||||
db, err := sql.Open("sqlite3", app.cfg.Database.Database)
|
||||
if err != nil {
|
||||
log.Error("%s", err)
|
||||
os.Exit(1)
|
||||
|
Reference in New Issue
Block a user