dbschema/database.go

32 lines
614 B
Go
Raw Permalink Normal View History

2023-08-01 17:10:35 +02:00
package dbschema
import (
// Standard
"database/sql"
"fmt"
)
func newDatabase(host string, port int, dbName, user, pass string) (dbase Database, err error) {// {{{
dbase.Host = host
dbase.Port = port
dbase.DbName = dbName
dbase.Username = user
dbase.Password = pass
dbase.db, err = sql.Open("postgres", dbase.sqlConnString())
return
}// }}}
func (dbase Database) sqlConnString() string {// {{{
return fmt.Sprintf(
"host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
2023-08-01 17:10:35 +02:00
dbase.Host,
dbase.Port,
dbase.Username,
dbase.Password,
2023-08-01 17:10:35 +02:00
dbase.DbName,
)
}// }}}
// vim: foldmethod=marker