1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

pg: add port to config

This commit is contained in:
Alexander Medvednikov 2020-03-06 02:01:53 +01:00 committed by GitHub
parent 7008b1a92c
commit efb45579aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ struct C.PGResult { }
pub struct Config {
pub:
host string
port int
user string
password string
dbname string
@ -35,7 +36,7 @@ fn C.PQexec(voidptr) voidptr
fn C.PQexecParams(voidptr) voidptr
pub fn connect(config pg.Config) ?DB {
conninfo := 'host=$config.host user=$config.user dbname=$config.dbname password=$config.password'
conninfo := 'host=$config.host port=$config.port user=$config.user dbname=$config.dbname password=$config.password'
conn := C.PQconnectdb(conninfo.str)
status := C.PQstatus(conn)
println("status=$status")