Build Your First App
⭐ Level - Beginner
⏱️ Time - 15 minutes
This tutorial guides you through the steps to create a simple database GUI using Dronahq. The application connects to a sample PostgreSQL database, allowing you to read and update customer information. You'll learn to:
- Create a new application.
- Connect to a database and fetch data.
- Display the data in a Tablegrid control.
- Build form to view customer details.
- Edit and update the customer detail.
- Publish the application
Here's a screenshot of the final result:
Let's get started!
Prerequisites
- An Dronahq account. If you don’t have one, sign up on Dronahq Cloud.
Create a new application
When you login into DronaHQ, it opens
My Apps
on the homepage by default. You need to create a new empty application for this tutorial. To create a new app, click the+
icon (which is usually the first icon on the screen). SelectBlank App -> Add App Name, Description, Logo -> CREATE APP
.Here, you can give App name as
Customer Management
, provide description asApp to manage customer info
and choose any logo.
- Blank App will open in a new tab with default
Screen 1
added.
Connect to a Datasource
Here, we will connect to a mysql
database.
- Go to
Connector Library -> + Connector -> MySQL
Enter
Connector Name
ascustomerTutorialDB
.Enter connector string which will be in a format represented below.
mysql://<username>:<pwd>@db-dhq.c8jniapv05hb.us-east-1.rds.amazonaws.com:3306/dbonbording
Click the
Test connection
button to test the connection and ensure the database is valid.
- Click
SAVE
to create and save the database connection. You'll see thecustomerTutorialDB
database in Connectors listing.
🚩 You've successfully connected to the MySQL database that contains customer information.
Fetch customer data and Display in Table Grid
Click the
Controls
option in navigation menu to the left of screen.Drag a
Table Grid
control and drop it to the on the canvas.Select
Table Grid
control and selectData
option in navigation menu to the right of screen.Select
Quick Select -> Connector Query -> customerTutorialDB
. It loads the query editor which list all the tables ofcustomerTutorialDB
database.Enter query name as
getCustomers
.Enter below query under
Write Your Query
to get first 10customers
.
select * from Customers ORDER BY id asc LiMIT 10;
- Click on
Test Query
and thenSave
this query once test is successful.
Under
Transform Response -> Filter Keys
you can choose the list of keys that will be displayed in Table Grid control. If no keys are selected then all the Keys will be selected.Click
Test & Save
. This will display customers list in Table Grid control.
🚩 You've created your first query to fetch the list of customers in the database and displayed the results from getCustomers query to Table Grid control.
Build form to view customer details
From the
Controls
option, drag and drop aContainer
control on the canvas to the right of the Table Grid control.Select
Container
control and on theproperty
pane to the right of the Screen, underLabel
section, turn off the hidden toggle and rename the Text toCustomer Details
from Container.Now add
Image
control in the above container. SelectImage
control, on thedata
pane to the right of the Screen, type{{tablegrid.avatar}}
and clickSave
.Now, add
Text Input
control in the above container, Select thisText Input
control- On the
property
pane to the right of the Screen, underLabel
section, rename the Text toFull Name
from Default value. - On the
data
pane to the right of the Screen, type{{tablegrid.fullname}}
and clickSave
.
- On the
Now, Let's do the same for Customer's department. Add another
Text Input
control in the above container, Select thisText Input
control- On the
property
pane to the right of the Screen, underLabel
section, rename the Text toDepartment
from Default value. - On the
data
pane to the right of the Screen, type{{tablegrid.department}}
and clickSave
.
- On the
Now, Let's do the same for Customer's email address. Add another
Text Input
control in the above container, Select thisText Input
control- On the
property
pane to the right of the Screen, underLabel
section, rename the Text toEmail
from Default value. - On the
data
pane to the right of the Screen, type{{tablegrid.email}}
and clickSave
.
- On the
And finally, for Customer's address, Add
Textarea
control in the above container, Select thisTextarea
control- On the
property
pane to the right of the Screen, underLabel
section, rename the Text toAddress
from Default value. - On the
data
pane to the right of the Screen, type{{tablegrid.address}}
and clickSave
.
- On the
🚩 You've completed binding the data to the controls on the Form. Select the rows on the Table Grid to view the corresponding customer details on the Form.
Update customer details
- Select
Connector Library -> customerTutorialDB -> + New Query
.
It loads the query editor which list all the tables of
customerTutorialDB
database.Enter query name as
updateCustomer
.Enter below query under
Write Your Query
to updateCustomers
table.
UPDATE Customers
SET fullname = "{{CustomerFullName}}",
department = "{{CustomerDepartment}}",
address = "{{CustomerAddress}}",
email = "{{CustomerEmail}}"
WHERE id = {{CustomerID}};
Provide Test values for CustomerID
field as 100
. For other fields you can provide provide any test value or keep it empty.
Click on
Test Query
and thenSave
this query once test is successful.Now, in our form, From the
Controls
option, drag and drop aButton
control in our Container control.Select this
Button
control- On the
property
pane to the right of the Screen, scroll down to thePROPERTIES
accordion, rename the Text toUpdate Customer
from Action. - On the
events
pane to the right of the Screen, selectbutton_click
event and follow below steps.
- On the
Click
+ (Add) -> Server Side Actions -> customerTutorialDB -> updateCustomer
Click
Continue
and provide following query parameters with that of corresponding control.- For CustomerAddress, Add
{{address}}
- For CustomerDepartment, Add
{{department}}
- For CustomerEmail, Add
{{email}}
- For CustomerFullName, Add
{{fullname}}
- For CustomerID, Add
{{tablegrid.id}}
- For CustomerAddress, Add
Click
Continue
and thenFinish
.In the success leg, we need to reload Tablegrid control's data to see the updated change. Click
+ (Add) -> Run Data Queries -> getCustomers
. ClickContinue
and thenFinish
.
Tablegrid control is getting data from getCustomers
data query. Thereby, triggering a change in getCustomers
data query by re-running it, the result will be passed to Table Grid control automagically.
Click on
Preview
button on the top right of the screen toTest
the application andFinally, click on
Publish
andEnter Release Notes -> Publish
to deploy your application. You can click onShare
option to view various sharing options usingOrganizational access or Public URL access
.
The databases used in tutorials are public and shared by all Dronahq users, so ensure that you don't input confidential information during testing. The Test databases automatically resets, so any updates made to these databases are temporary
🚩 Congratulations on successfully building your first app that can display data from the database and save the updated data back into the database using Form.
In this tutorial, you explored a few different controls and created a simple database GUI to view, query, and update data on a sample MySQL database. You can use these skills to build your own app.