[WIP] migration to psql
TODO: [ ] stats [ ] indexes
This commit is contained in:
parent
e1bd235785
commit
e72de38725
24 changed files with 648 additions and 936 deletions
15
main.go
15
main.go
|
@ -15,7 +15,9 @@ import (
|
|||
func main() {
|
||||
var (
|
||||
httpAddr = flag.String("addr", ":8080", "HTTP service address")
|
||||
dbIP = flag.String("db-ip", "127.0.0.1", "IP address of the database")
|
||||
dbAddr = flag.String("db-addr", "localhost:5432", "IP address of the database")
|
||||
dbUser = flag.String("db-user", "", "User name to access the database")
|
||||
dbPassword = flag.String("db-password", "", "Password to access the database")
|
||||
dbName = flag.String("db-name", "trantor", "Name of the database")
|
||||
storePath = flag.String("store", "store", "Path of the books storage")
|
||||
assetsPath = flag.String("assets", ".", "Path of the assets (templates, css, js, img)")
|
||||
|
@ -32,7 +34,16 @@ func main() {
|
|||
}
|
||||
log.Info("Start the imperial library of trantor")
|
||||
|
||||
db := database.Init(*dbIP, *dbName)
|
||||
db, err := database.Init(database.Options{
|
||||
Addr: *dbAddr,
|
||||
User: *dbUser,
|
||||
Password: *dbPassword,
|
||||
Name: *dbName,
|
||||
})
|
||||
if err != nil {
|
||||
log.Critical("Problem initializing database: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
store, err := storage.Init(*storePath)
|
||||
|
|
Reference in a new issue