Today we announced support for PostgreSQL and Postgres Plus databases in Bungee-powered applications. This new capability represents another step toward providing developers with the most flexibility in managing, hosting and using their data in Bungee-powered applications.
Working with SQL-based databases inside of Bungee Connect is pretty straight forward. There are several tools to help you, such as:
- SQL Console – Work directly with the database during development using the database console. Simply type in your statement and see the returned results below. This is a very handy way to work with your database, including adding/removing tables or columns or test out statements from your application.
- Event Viewer – Through the event viewer you can see the statement sent to the database server and the results that were returned. During simulation the event viewer will log all the requests to the server and the responses, making it easy to debug your application and ensure it is doing exactly what you expected.
- Connection Config – Simply enter your credentials and you’re connected. Of course, you can switch between sandbox and production environments programmatically.
Just this week we have also released a developer sample application powered by MySQL. This article covers this storefront developer sample. Note: When you import the sample application a sandbox database will be automatically created for you, simply simulate and get started.
The documentation team has also been hard at work documenting the integration of SQL databases into Bungee-powered applications. You can find that documentation here. Though written for MySQL you can use it for PostgreSQL databases, the concepts are the same with a few slight differences.
Postgres has a schema layer within the database. Tables are within the schema. When querying a database table you need to include the schema in dotted notation before the table name. Where the MySQL query would be “select * from itemsTable” the Postgres query would be “select * from schemaName.itemsTable”.
MySQL uses the lastInsertID function to get the primary key for the most recent inserted row in a table. For Postgres, you need to query such as “select currval(‘schemaName.tableNameidColumnNameseq’)”. Where schemaName, tableName and idColumnName are replaced by the values of your schema, table and column name. This query can be executed using the queryOneResult function which will return the id of the last inserted row.
As always, we are interested in your feedback on this new capability and how Bungee Connect can better meet your needs.