[Top]
Sql
Sql.pgsql
|
Method Sql.pgsql()->create()
- Method
create
-
void Sql.pgsql()
void Sql.pgsql(string host, void|string database, void|string user, void|string password, void|mapping(string:mixed) options)
- Description
-
With no arguments, this function initialises (reinitialises if a
connection has been set up previously) a connection to the
PostgreSQL backend. Since PostgreSQL requires a database to be
selected, it will try to connect to the default database. The
connection may fail however, for a variety of reasons; in this case
the most likely reason is because you don't have sufficient privileges
to connect to that database. So use of this particular syntax is
discouraged.
- Parameter host
-
Should either contain "hostname" or
"hostname:portname" . This allows you to specify the TCP/IP
port to connect to. If the parameter is 0 or "" ,
it will try to connect to localhost, default port.
- Parameter database
-
Specifies the database to connect to. Not specifying this is
only supported if the PostgreSQL backend has a default database
configured. If you do not want to connect to any live database,
you can use template1 .
- Parameter options
-
Currently supports at least the following:
"use_ssl" : int | If the database supports and allows SSL connections, the session
will be SSL encrypted, if not, the connection will fallback
to plain unencrypted
|
"force_ssl" : int | If the database supports and allows SSL connections, the session
will be SSL encrypted, if not, the connection will abort
|
"cache_autoprepared_statements" : int | If set to zero, it disables the automatic statement prepare and
cache logic; caching prepared statements can be problematic
when stored procedures and tables are redefined which leave stale
references in the already cached prepared statements
|
"client_encoding" : string | Character encoding for the client side, it defaults to using
the default encoding specified by the database, e.g.
UTF8 or SQL_ASCII .
|
"standard_conforming_strings" : string | When on, backslashes in strings must not be escaped any longer,
quote() automatically adjusts quoting strategy accordingly
|
"escape_string_warning" : string | When on, a warning is issued if a backslash (\) appears in an
ordinary string literal and standard_conforming_strings is off,
defaults to on
|
|
For the numerous other options please check the PostgreSQL manual.
- Note
-
You need to have a database selected before using the sql-object,
otherwise you'll get exceptions when you try to query it. Also
notice that this function can raise exceptions if the db
server doesn't respond, if the database doesn't exist or is not
accessible by you.
- See also
-
Postgres.postgres , Sql.Sql , select_db() ,
http://search.postgresql.org/search?u=%2Fdocs%2F&q=client+connection+defaults
|