Creating your first SQL Query
Once you have set up your first Datasource, you will be able to create Queries in the PocketQuery admin. For this, head over to the Queries tab.
On the Queries tab, you will be able to create your first Query by clicking the “Let’s create my first Query!” button.
Our research database contains a rather simple author
table that we can use. So let’s name our Query “Rfam Authors”, select the “Rfam” Datasource, and insert this SQL statement:
SELECT author_id, name, last_name
FROM author
Finally, hit “Create Query” to save your first SQL Query. You can now execute it, using the PocketQuery macro in one of your Confluence pages. So, create a new Confluence page and insert a PocketQuery macro by typing /PocketQuery
.
This will open the PocketQuery macro editor. Here you can select your “Rfam Authors” Query that you have just created. Hit “Insert” to insert the macro with the selected Query into your page.
After inserting the macro into your page, PocketQuery will execute your SQL against the database and present you with the results.
That’s it! Easy, right? You now know how to use PocketQuery to pull in data from a database into your Confluence page. But there’s actually a lot more you can do with PocketQuery. For example, you can define parameters in your SQL statement to make your Queries more dynamic and reusable. Want to see how?
Continue with “Adding parameters to your Query“