Used to connect to a PostgreSQL database.
In order to use this class, you must have the PostgreSQLPlugin database plug-in in your plugins folder.
The PostgreSQL plug-in supports MD5 password authentication.
A field specified as type Float is actually implemented by PostgreSQL as a double (8 bytes).
PostgreSQL dates: field types Date, Time, and TimeStamp are supported by using the DateColumn and DateValue methods for a date representation of this data, or use StringValue to get a human-readable date and/or time.
The PostgreSQLDatabase engine supports only the MoveNext RecordSet navigation method.
Also be sure to refer to the official PostgreSQL documentation.
SQLSelect and SQLExecute statements do not block when called from within Threads.
Xojo Cloud includes built-in support for PostgreSQL databases, which you can enable in your Xojo Cloud control panel.
To access an external PostgreSQL databases from web apps running on Xojo Cloud, you will first have to use the FirewallPort class to open the port used to connect to PostgreSQL, which is usually 5432.
fwp.Open // This call is synchronous
If fwp.IsOpen Then
// Do what you need to do
Refer to the Xojo Cloud page for more information about using PostgreSQL with Xojo Cloud.
PostgreSQLDatabase implements PostgreSQL's large objects. PostgreSQL requires that all large object operations be performed inside of a transaction. Therefore, you must start a transaction before you perform your first large object operation:
After you have performed your last large object operation, you should close the transaction, like this:
Please see the PostgreSQLLargeObject class for information on how to work with large objects.
Listen and Notify Protocol
The PostgreSQLDatabase class implements the listen and notify protocol of PostgreSQL databases.
To send a notification, call the PostgreSQLDatabase.Notify method with the name of the notification you want to send. For example, if you wanted to send a notification called "Hello World", you would call Notify like this:
To check for notifications, call the PostgreSQLDatabase.CheckForNotifications method. You will receive notifications as a PostgreSQLDatabase.ReceivedNotification event. The ReceivedNotification event is called with three arguments: the name of the notification as a String, the ID of the process sending the notification as an Integer, and an extra argument that the PostgreSQL documentation says is not used at this time. The name parameter is the same name that you used with the Notify method.
If you would like to check for notifications automatically, at some set interval, then use a Timer and call CheckForNotifications in its Action event.
This example opens an existing PostgreSQL database.
db.Host = "192.168.1.172"
db.Port = 5432
db.DatabaseName = "myDatabase"
db.AppName = "MyApp"
db.Username = "Charlie"
db.Password = "mashie"
If db.Connect Then
//proceed with database operations
MsgBox("The connection failed.")
- Example Projects/Database/PostgreSQL/LargeObjects
- Example Projects/Database/PostgreSQL/ListenAndNotify