UsePostgreSQLDatabase()
Syntax
Result = UsePostgreSQLDatabase([LibraryName$])Description
Initialize the PostgreSQL database environment for future use.
Parameters
LibraryName$ (optional) Filename (and path if needed) of the dynamic library to use. It could be useful to use a different version of the library that the one included with PureBasic. If this parameter is not specified, the internal postgresql client library shipped with PureBasic will be used (no external dynamic library needed).
Return value
When using the optional 'LibraryName$' parameter, it will return #True if the dynamic library has been correctly loaded or #False otherwise. If the optional 'LibraryName$' parameter is not specified, it will always returns #True.
Remarks
PostgreSQL is a powerful, server based database manager which support very large database and high concurrency. It is free to use in commercial projects, unlike MySQL which requires a licence to use it in a non-GPL program. There is no additional driver to install, all is ready to connect a PostgreSQL server. For more information about PostgreSQL: http://www.postgresql.org.
A PostgreSQL database has to be connected using OpenDatabase() before using any other database functions. PostgreSQL specific parameters can be passed in the 'DatabaseName$' parameter of OpenDatabase():- host: Name of host to connect to. - hostaddr: Numeric IP address of host to connect to. - port: Port number to connect to at the server host. - dbname: The database name. Defaults to be the same as the user name. - connect_timeout: Maximum wait for connection, in seconds (write as a decimal integer string). Zero or not specified means wait indefinitely. It is not recommended to use a timeout of less than 2 seconds.
Example
UsePostgreSQLDatabase() ; You should have a server running on localhost ; If OpenDatabase(0, "host=localhost port=5432", "user", "password") Debug "Connected to PostgreSQL" Else Debug "Connection failed: "+DatabaseError() EndIf
See Also
OpenDatabase(), UseSQLiteDatabase(), UseODBCDatabase(), UseMySQLDatabase()
Supported OS
All