🗄️

Databases

 
Pico doesn’t fully support databases (that’s on our roadmap). Currently, we support a minimal database in the form of a Google Sheet. You can ✅ read and ✅ write to a Google Sheet. But you can’t ❌ edit or ❌ delete data in the Google Sheet.
 
 

Use Cases

 
  • Store recently created content and show it to the user (for example: ”5 Recent Essays”)
  • Store user responses (remember for MetaGPT and Chatbots, you can see all responses and chats without a database by going into the Analytics section)
  • Read a large collections of data from a Google Sheet
 
đź’ˇ Tip: For another way to capture data, use the Email Yourself API. That API can be used to send yourself a new email whenever something happens within your app, for example, when the user submits a feedback form. You can also combine both APIs. For instance, you can build a feedback form, where the data is sent to the Google Sheet for future reference, and you also get notified immediately by email.

Create a Database

Before you can use a Google Sheet as your database, you need to create a new Google Sheet that’s connected to your Pico app.
While editing your app, open up the Database panel in the sidebar and click on “Create Database”.
 
notion image
After the Google Sheet is created, you should see a “View App Database” button that will take you to the Google Sheet. You can view and edit the data directly in the Google Sheet as you need to.
 

Writing Data

 
Once your database is created, if you use the magic word “database” in your prompt, Pico will know to write to and read from your Google Sheet. Here’s an example prompt:
 
  • “When the submit button is clicked, save the form values in the database”
 
Pico will put the data into a new Sheet on your Google Sheet. The sheet name will be determined by the AI. If you’d like to change it, edit the code directly and prompt Pico to update the “table_name”.

Reading Data

 
In order to get your app to read data, prompt similarly to the previous section. If the app is also writing to the same table/sheet, the name and the columns in the table will be understood by Pico.
 
If you want to read data from the Google Sheet and you set up the columns in particular way, make sure to describe to Pico the sheet structure. For example:
 
  • “Read the list of countries and populations from the table named population_data. It has two columns country and population”

Video Tutorial

 
Here is a video tutorial on how to use the database feature to store the responses generated by your MetaGPT app and show the last 5 response in your app.
 
Video preview
 

Troubleshooting Tips

 
  • When you retrieve data from the database, make sure to ask it to display the data somewhere on the UI for easier debugging. You can remove this later in the final version.
  • DON’T refer to the database as "Google Sheet", that will confuse the AI. Use the magic keyword “database”.
  • With MetaGPT and Chatbot apps that support streaming (the response is displayed word for word to the user as it is generated), occasionally, every word will be written as a separate row in the Google Sheet. To fix this problem, go to your history, revert the change you just made, and retry. You can also try instructing the AI to "wait until the response is fully loaded and complete before writing to the database".
Â