Skip to main content
This custom layer has been tested for PostgreSQL, however it should support more SQL databases thanks to the use of the SQL Alchemy database. This data layer also supports the BaseStorageClient that enables you to store your elements into Azure Blob Storage or AWS S3.
The schema below reflects the latest version of Chainlit. If you are upgrading from an earlier version, three columns have been added to the steps table since 2.0.0:
Here is the SQL used to create the schema for this data layer:

Example

Here is an example of setting up this data layer on a PostgreSQL database with an Azure storage client. First install the required dependencies:
Import the custom data layer and storage client, and indicate which data layer to use with @cl.data_layer at the beginning of your Chainlit app:
Note that you need to add +asyncpg to the protocol in the conninfo string so that it uses the asyncpg library.