Data Sources
Integrating data sources with Dropbase works the same way as when you develop other software: you add all keys, tokens, and database credentials via your .env files directly in your code base.
This way, only you have access to your credentials and you can add anything you want. Creds in the .env file are not shared with Dropbase.
Adding Data Sources
When you set up the Dropbase worker locally in your development machine, you will have this configuration in your .env
file:
DROPBASE_TOKEN='YOUR_WORKSPACE_TOKEN'
DROPBASE_API_URL="https://api.dropbase.io"
To add a database source or an API token, simply add your database credentials in the file and save.
Here's an sample .env file after you've added a Postgres database as a data source:
DROPBASE_TOKEN='YOUR_WORKSPACE_TOKEN'
DROPBASE_API_URL="https://api.dropbase.io"
# YOURDB CREDS
SOURCE_PG_YOURDB_HOST="YOUR_DATABASE_HOST"
SOURCE_PG_YOURDB_DATABASE="YOUR_DATABASE_NAME"
SOURCE_PG_YOURDB_USERNAME="YOUR_DATABASE_USERNAME"
SOURCE_PG_YOURDB_PASSWORD="YOUR_DATABASE_PASSWORD"
SOURCE_PG_YOURDB_PORT=5432
Naming Your Data Source
Database source variables have a specific pattern that help Dropbase use the correct credentials when making queries via the UI.
[SOURCE]_[DATABASE TYPE]_[DATABASE NICKNAME]_[PROPERTY]=[VALUE]
SOURCE
: Specifies that this is a data sourceDATABASE TYPE
: Specifies the type of database you are adding e.g. for Posgtres database, addPG
DATABASE NICKNAME
: Specifies the nickname for this database. This is used to set you select which source to use when writing functions to query data in Dropbase e.g.YOURDB
orSTAGING
PROPERTY
: Specifies the credential property e.g. for Postgres, you must specify thePORT
number.VALUE
: Specifies the value for the corresponding property e.g. for PostgresPORT
number will usually be5432
Data Source Nick Name
In the previous example, we used YOURDB
as the nickname for the database credentials. You can change this to anything you want!
Simply replace YOURDB
with the nickname you want to associate with the set of database credentials supplied. Dropbase will use this nickname to identify the database source when you write functions to query data in Dropbase.