Built-in Storage

Databutton provides built-in storage capabilities out of the box.

All operations, such as storing and retrieving data, are managed by the Databutton Agent using Databutton's own Python SDK.

File Types: Store and Retrieve

Commonly used file types for storage and retrieval are jotted down below.

File Type

Store Method

Retrieve Method

Description

Text Files

db.storage.text.put()

db.storage.text.get()

Handle plain text-based files like .txt, .html, or .md.

JSON Files

db.storage.json.put()

db.storage.json.get()

Save JSON files as Python dictionaries.

Binary Files

db.storage.binary.put()

db.storage.binary.get()

Save raw binary files or any unknown file types as Python byte objects.

Dataframes

db.storage.dataframes.put()

db.storage.dataframes.get()

Store and retrieve tabular data, such as CSV files, in Pandas DataFrame format.

Pickled Objects

db.storage.binary.put()

db.storage.binary.get()

Store Python objects serialized with pickle.

Other File Types

db.storage.binary.put()

db.storage.binary.get()

Manage custom or unknown file types using binary storage methods.

How the Databutton Agent Performs Operations

The Databutton Agent simplifies the process of storing and retrieving files by leveraging Databutton's internal Python SDK. The agent uses simple methods like put() and get()

Example prompt to store data:

Hey, I want to store this scrappped data as a JSON file using Databutton's built-in storage. Ensure it's accessible for retrieval later.

FAQs: Databutton Built-in Storage

Shall I use this internal storage or go for alternatives?

We recommend using alternatives like Firebase or Supabase for production-ready apps. Databutton's internal storage is primarily designed for testing and development purposes. However, if you're building a small-scale app with basic storage needs, feel free to use it.

Can I manually upload files to the internal storage?

Yes! You can manually upload files by clicking the "Add File" button in the sidebar.

  • CSV Files: Automatically converted into a Pandas dataframe.

  • JSON Files: Stored as Python dictionaries.

  • Text Files: Formats like .txt, .html, or .md are stored as plain text and accessible as Python strings.

  • Other File Types: Uploaded as raw binary and accessible in code as Python bytes.

How much data can we store?

Currently, there are no specific storage limits. However, if any changes are made, you will be notified. We encourage responsible use of resources and recommend avoiding misuse.

Can the agent write and read files?

Yes, the Databutton Agent can write and read files. Simply provide a concise and detailed prompt for the agent. If necessary, include more details about your storage requirements. Use #<filename> to reference specific files.

How to work on files stored in Databutton's internal storage?

You can work with these files by creating backend functions that interact with the storage. The backend handles the file operations (such as reading, writing, or processing), and you can pass the results to the frontend or other parts of your app for further use.

Can I download those files?

Absolutely! You can download files by selecting the specific file from the Databutton interface and clicking the download button.

Hands-On with Databutton Storage

Uploading a CSV File

Once uploaded, Databutton automatically converts the CSV file into a Pandas dataframe and enables visualization of the dataframe within an interactive AgGrid table

Prompting the Agent to read CSV files in storage

To read a CSV file stored in Databuttonโ€™s internal storage, simply prompt the agent, e.g., "Hi, can you read the #storage-dataframe-storage/dummy-data-csv and let me know its content?" The Databutton Agent will use the internal SDK to locate and read the file, then display its content directly in the chat.

Using Files from Databutton's Internal Storage

Files stored in Databutton's internal storage are accessible only via the backend. To use them in the frontend, you need to first create a backend function to handle the file, and then pass the processed data to the frontend.

Example Prompt: "Hi! Can you write a backend that would read the #storage-dataframe-storage/dummy-data-csv, extract the data, and put it in the #page/Home?"

The Databutton Agent will:

  1. Write a backend function to read the CSV file using the internal storage methods.

  2. Process the data in the backend.

  3. Pass the extracted data to the specified frontend page for display or further interaction.

Last updated