Skip to main content
You can store and retrieve data from Data Stores in Python without connecting to a 3rd party database. Add a data store as a input to a Python step, then access it in your Python handler with pd.inputs["data_store"].

Adding a Data Store

Click Add Data Store near the top of a Python step:
This will add the selected data store to your Python code step.

Saving data

Data stores are key-value stores. Saving data within a data store is just like setting a property on a dictionary:

Setting expiration (TTL) for records

You can set an expiration time for a record by passing a TTL (Time-To-Live) option as the third argument to the set method. The TTL value is specified in seconds:
When the TTL period elapses, the record will be automatically deleted from the data store.

Updating TTL for existing records

You can update the TTL for an existing record using the set_ttl method:
This is useful for extending the lifetime of temporary data or removing expiration from records that should now be permanent.

Retrieving keys

Fetch all the keys in a given data store using the keys method:
The data_store.keys() method does not return a list, but instead it returns a Keys iterable object. You cannot export a data_store or data_store.keys() from a Python code step at this time.Instead, build a dictionary or list when using the data_store.keys() method.

Checking for the existence of specific keys

If you need to check whether a specific key exists in a data store, use if and in as a conditional:

Retrieving data

Data stores are very performant at retrieving single records by keys. However you can also use key iteration to retrieve all records within a Data Store as well.
Data stores are intended to be a fast and convenient data storage option for quickly adding data storage capability to your workflows without adding another database dependency.However, if you need more advanced querying capabilities for querying records with nested dictionaries or filtering based on a record value - consider using a full fledged database. Pipedream can integrate with MySQL, Postgres, DynamoDb, MongoDB and more.

Get a single record

You can retrieve single records from a data store by key:
Alternatively, use the data_store.get() method to retrieve a specific key’s contents:
What’s the difference between data_store["key"] and data_store.get("key")?
  • data_store["key"] will throw a TypeError if the key doesn’t exist in the data store.
  • data_store.get("key") will instead return None if the key doesn’t exist in the data store.
  • data_store.get("key", "default_value") will return "default_value" if the key doesn’t exist on the data store.

Retrieving all records

You can retrieve all records within a data store by using an async iterator:
This code step example exports all records within the data store as a dictionary.

Deleting or updating values within a record

To delete or update the value of an individual record, assign key a new value or '' to remove the value but retain the key.

Working with nested dictionaries

You can store dictionaries within a record. This allows you to create complex records. However, to update specific attributes within a nested dictionary, you’ll need to replace the record entirely. For example, the code the below will not update the name attribute on the stored dictionary stored under the key pokemon:
Instead, overwrite the entire record to modify attributes:

Deleting specific records

To delete individual records in a data store, use the del operation for a specific key:

Deleting all records from a specific data store

If you need to delete all records in a given data store, you can use the clear method.
data_store.clear() is an irreversible change, even when testing code in the workflow builder.

Viewing store data

You can view the contents of your data stores in your Pipedream dashboard. From here you can also manually edit your data store’s data, rename stores, delete stores or create new stores.

Workflow counter example

You can use a data store as a counter. For example, this code counts the number of times the workflow runs:

Dedupe data example

Data Stores are also useful for storing data from prior runs to prevent acting on duplicate data, or data that’s been seen before. For example, this workflow’s trigger contains an email address from a potential new customer. But we want to track all emails collected so we don’t send a welcome email twice:

TTL use case: temporary caching and rate limiting

TTL functionality is particularly useful for implementing temporary caching and rate limiting. Here’s an example of a simple rate limiter that prevents a user from making more than 5 requests per hour:
This pattern can be extended for various temporary caching scenarios like:
  • Session tokens with automatic expiration
  • Short-lived feature flags
  • Temporary access grants
  • Time-based promotional codes

Supported data types

Data stores can hold any JSON-serializable data within the storage limits. This includes data types including:
  • Strings
  • Dictionaries
  • Lists
  • Integers
  • Floats
But you cannot serialize Modules, Functions, Classes, or other more complex objects.