This repository contains helper scripts that interact with the Budibase public API to export table rows to CSV and import CSV data back into Budibase.
- Node version 12 and above
- Clone the repo.
git clonethe repo.cdto the folder its located.npm installinside the repo.- Rename the file
.env-templateto.env.
- Get your Budibase API Key.
- Login to your Budibase instance.
- Click on your avatar at the top right of the page.
- Click
View API Key, a popup should occur.
* Copy your API key from the window.
* Paste your API into `BUDIBASE_API_KEY` within the `.env` file.
- Get your appID.
- Click into the app you wish to use this exporting codebase with.
- Look for the URL and copy the part of the URL that looks similar to this;
app_dev_cloudtestbb_28a92365115s234925b0cb28af1a27a17542- Paste your appID into
APP_IDwithin the.envfile.
- Paste your appID into
- Get your tableID
- Find the table you wish to export.
- Look at the url after
table/you should find your table id. - It should look something like this;
ta_3946749e5d814449bdd51a5ec37d58e2if its an external db and not an internal table it should look like this instead:datasource_plus_466537f1996c4d99add97f652378812b__posts_final. - Paste your tableID into
TABLE_IDwithin the.envfile.
- (Optional) Set a custom CSV path for imports.
- Update
IMPORT_FILEin.envif you want to import from a file other thaninput.csv.
- Update
npm run export– exports the configured table tooutput.csv. (Duration depends on table size.)npm run import– imports rows frominput.csv(or the file set viaIMPORT_FILE) into the configured table.
You won't be able to export relationships, through testing I was able to pull the relevant _ids needed for relationships. However, when trying to re-import the CSV into the table again it ignored the relationship. I may do additional testing to see if there is a workaround.
The import script also skips Budibase metadata fields (for example _id or _rev) and empty values so that only user-defined fields are sent to the API.
Find out more about Budibase.
