[Top]
Sql
Sql.postgres
|
Method Sql.postgres()->create()
- Method
create
void Sql.postgres()
void 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.
The username and password arguments are silently ignored, since
the Postgres C API doesn't allow to connect to the server as any
user different than the user running the interface.
- 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.
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
|