|
|
@ -486,7 +486,11 @@ func connectToDatabase(app *app) { |
|
|
|
db, err = sql.Open(app.cfg.Database.Type, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()))) |
|
|
|
db, err = sql.Open(app.cfg.Database.Type, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()))) |
|
|
|
db.SetMaxOpenConns(50) |
|
|
|
db.SetMaxOpenConns(50) |
|
|
|
} else if app.cfg.Database.Type == "sqlite3" { |
|
|
|
} else if app.cfg.Database.Type == "sqlite3" { |
|
|
|
db, err = sql.Open("sqlite3", "./writefreely.db?parseTime=true&cached=shared") |
|
|
|
if app.cfg.Database.FileName == "" { |
|
|
|
|
|
|
|
log.Error("SQLite database filename value in config.ini is empty.") |
|
|
|
|
|
|
|
os.Exit(1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
db, err = sql.Open("sqlite3", app.cfg.Database.FileName+"?parseTime=true&cached=shared") |
|
|
|
db.SetMaxOpenConns(1) |
|
|
|
db.SetMaxOpenConns(1) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Error("Invalid database type '%s'. Only 'mysql' and 'sqlite3' are supported right now.", app.cfg.Database.Type) |
|
|
|
log.Error("Invalid database type '%s'. Only 'mysql' and 'sqlite3' are supported right now.", app.cfg.Database.Type) |
|
|
|