32 lines
614 B
Go
32 lines
614 B
Go
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",
|
|
dbase.Host,
|
|
dbase.Port,
|
|
dbase.Username,
|
|
dbase.Password,
|
|
dbase.DbName,
|
|
)
|
|
}// }}}
|
|
|
|
// vim: foldmethod=marker
|