Add docs for connecting to postgres with keyword/value connection
strings.
This commit is contained in:
parent
32d2327be0
commit
20661c9c46
1 changed files with 15 additions and 0 deletions
|
|
@ -180,6 +180,21 @@ proc Open*(connection, user, password, database: string): TDbConn {.
|
||||||
tags: [FDb].} =
|
tags: [FDb].} =
|
||||||
## opens a database connection. Raises `EDb` if the connection could not
|
## opens a database connection. Raises `EDb` if the connection could not
|
||||||
## be established.
|
## be established.
|
||||||
|
##
|
||||||
|
## Clients can also use Postgres keyword/value connection strings to
|
||||||
|
## connect.
|
||||||
|
##
|
||||||
|
## Example:
|
||||||
|
##
|
||||||
|
## .. code-block:: nimrod
|
||||||
|
##
|
||||||
|
## con = Open("", "", "", "host=localhost port=5432 dbname=mydb")
|
||||||
|
##
|
||||||
|
## See http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
|
||||||
|
## for more information.
|
||||||
|
##
|
||||||
|
## Note that the connection parameter is not used but exists to maintain
|
||||||
|
## the nimrod db api.
|
||||||
result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
|
result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
|
||||||
if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil
|
if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue