App SQL Access
Apps can register SQL access to be used by the app. This is useful for apps that need to query the database for data.
There are 2 types of SQL access:
- Pre-defined SQL queries: These are predefined SQL
SELECT
queries that are declared in the app manifest. The app can then execute these queries with the API. - Tables permissions: This is a special type of SQL access that allows the app to connect directly to the database with the MySQL protocol and access specific tables with read / write permissions. This should be used with caution and only when necessary. It is recommended to use this access for apps who need to import their data (Google Ads clicks etc…).
Pre-defined SQL queries
Declaring your queries in the app manifest.json allows the app to be more secure and performant. The app can also be more easily audited for security and performance.
Usage in the app
You can execute a pre-defined SQL query by calling the POST /api/app.execQuery
API endpoint with:
Tables permissions
By default, all the custom app tables declared in the app manifest.json are available with read & write permissions SELECT
, INSERT
, UPDATE
, DELETE
.
SELECT
) permissions.SQL credentials
When the app has tables permissions, the app can connect to the database with the MySQL protocol.
The SQL credentials (host, port, user, password, database) are provided by the API by calling the endpoint:
GET htttps://API_ENDPOINT/api/app.get?workspace_id=acme_workspace1&id=appx_myapp