Method Sql.postgres()->create()


Method create

Sql.postgres Sql.postgres()
Sql.postgres Sql.postgres(string host, void|string database, void|string user, void|string password, void|mapping options)

Description

With no arguments, this function initializes (reinitializes if a connection had been previously set up) a connection to the Postgres backend. Since Postgres 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 of all is because you don't have enough authority to connect to that database. So use of this particular syntax is discouraged.

The host argument can have the syntax "hostname" or "hostname:portname". This allows to specify the TCP/IP port to connect to. If it is 0 or "", it will try to connect to localhost, default port.

The database argument specifies the database to connect to. If 0 or "", it will try to connect to the specified database.

Note

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.

You don't need bothering about syncronizing the connection to the database: it is automatically closed (and the database is sync-ed) when the object is destroyed.

See also

Sql.pgsql, Postgres.postgres, Sql.Sql, postgres->select_db