Use MySQL instead of SQLite

This commit is contained in:
nemunaire 2016-01-23 13:16:31 +01:00
commit 8788eea4f0
4 changed files with 72 additions and 49 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"math/rand"
@ -42,7 +43,7 @@ func watchsubdir(watcher *inotify.Watcher, pathname string) error {
}
func main() {
var dbfile = flag.String("db", "fic.db", "Path to the DB")
var dsn = flag.String("dsn", "fic:fic@/fic", "DSN to connect to the MySQL server")
flag.StringVar(&BaseURL, "baseurl", "http://fic.srs.epita.fr/", "URL prepended to each URL")
flag.StringVar(&SubmissionDir, "submission", "./submissions", "Base directory where save submissions")
flag.StringVar(&TeamsDir, "teams", "../TEAMS", "Base directory where save teams JSON files")
@ -60,7 +61,7 @@ func main() {
}
log.Println("Opening DB...")
if err := fic.DBInit(*dbfile); err != nil {
if err := fic.DBInit(fmt.Sprintf("%s?parseTime=true", *dsn)); err != nil {
log.Fatal("Cannot open the database: ", err)
os.Exit(1)