Who can use the database integration?
|Plan availability:|| Trial|| Starter|| Growth|| Company|
In this article, we'll show you how to create a widget powered by your PostgreSQL database for your Geckoboard dashboard.
This integration is currently in beta.
So far, PostgreSQL is the only type of SQL database we support. More will be added very soon, but you can request support for your SQL database type.
We've tested this beta on PostgreSQL versions 11.1, 10.6, 9.6, 9.5 and 9.4.
There are some limitations to the beta and you may see additions and improvements to it over time. If you discover any bugs, or would like to share any feedback or feature requests for this integration, please email us at firstname.lastname@example.org.
You may need to ask a system admin for your SQL database information.
Also, be mindful of the permissions given to the database user used to connect to the database. This may result in them having permission to display confidential information, such as a list of users in the database.
Add a new Database widget
To add a new Database widget to your dashboard, follow these steps.
- Hover your cursor over the empty dashboard square you would like to position your widget and click the + button.
Alternatively, click Add widget, located in the top right of your dashboard.
- Search for Database using the Search sources field.
Alternatively, you can also scroll down the alphabetical list of integrations until you reach the Database integration.
- Click on the Database integration.
- Is your first connection? Click
Your database must be publicly accessible via the internet, have SSL encryption enabled, and be allowed to accept incoming connections from Geckoboard IP addresses.
. Otherwise, in the panel, click .
- On the Connect to Database panel, choose a Database type.
- Type in the Connection name. Give it a memorable name that helps you remember this connection.
- Type in the Host and Port. By default the port is set to 5432.
- Type in the Database name.
- Type in the database Username and Password
- Click .
- In the pop-up window that appears Paste your SQL query and click
Before you start
Queries don't need to be terminated with a semicolon (
You can load data from
viewsas well as
viewis named stored query that provides another way to present data in the database tables.
. We encourage you to write your query elsewhere before copying and pasting into this window.
- You will see a confirmation that your query was run successfully. Depending on your query you will see one or more highlighted visualization options. Hovering over each visualization type will tell you why it was, or wasn’t, suitable for your query.
When creating a line chart, the first column is the x axis and must be a time stamp.
- To add a widget, hover over your chosen visualization type and click the + button that replaces it.
- And that's it! Your new widget will now appear on your dashboard.
Data definition queries such as
DROP TABLE will return an error if run in the SQL code window. This is because queries run by the Database integration are read only.
Unsupported data types
Jsonb data type
Jsonb is not supported. To display
jsonb data, you'll need to use
CAST to convert it to another data type.
Example of using
CAST to convert a
To convert a
jsonb data type, use:
SELECT surname, CAST(address as varchar) FROM gecko_keepers WHERE title = 'Dr
One value from the
jsonb can be displayed as text in a table visualization by using this query:
SELECT surname, address ->> 'road' AS road FROM gecko_keepers WHERE title = 'Dr
Money data type
Money is not a supported datatype, and so will not be displayed in visualizations.
Money can be displayed in a table by using
CAST to convert from one data type into another.
Example of using
CAST to convert currencies
To convert a currency to numeric, use:
SELECT destination_id, TRUNC(CAST(value_of_food_money AS NUMERIC)) AS Value, shipping_date from shipping_geckos
Minimum and maximum values
You might experience a loss in precision when using
decimal types with large numbers or very small negative numbers.
The integer type
Bigint currently doesn't support
maxJSSafeInteger. Read more about floating point numbers.
Bigint types not only consume a lot of storage but also decrease the performance of the database, therefore, you should have a good reason to use it.
The following table illustrates the minimum and maximum values for integer and serial types:
|Data type||Min value||Max value|
When choosing how many decimal points you'd like, it's best to use the
TRUNC returns a truncated value of a number or a datetime value. For more information, see PostgreSQL's list of Mathematical Functions and Operators.
Example uses of
mean_temperature_c to 2 decimal points, use:
SELECT date_first_shipped_to, TRUNC(mean_temperature_c,2) as Temperature FROM destinations;
For no decimal points, use:
SELECT date_first_shipped_to, TRUNC(gravity) FROM destinations;