TheMathemagicians/sevenkeys/cmd/dbup/main.go

33 lines
496 B
Go
Raw Normal View History

2024-04-14 20:28:35 +00:00
package main
import (
"encoding/json"
"log"
"os"
"sevenkeys/database"
"github.com/go-sql-driver/mysql"
)
func readConfigFromFile(filename string) mysql.Config {
bytes, err := os.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
var config mysql.Config
err = json.Unmarshal(bytes, &config)
if err != nil {
log.Fatal(err)
}
return config
}
func main() {
config := readConfigFromFile("config.json")
db := database.GetDatabase(config)
database.CreateDatabaseSchema(db)
}