Choose one of the following options for your open source data layer:

  • use the official Chainlit data layer (PostgreSQL + asyncpg)
  • leverage a community-based data layer
  • or build your own!

Official data layer

When using the official data layer, just add the DATABASE_URL variable to your .env and a cloud storage configuration if relevant.

Community data layers

For community data layers, you need to import the corresponding data layer in your chainlit app. Here is how you would do it with SQLAlchemyDataLayer:

import chainlit as cl

from chainlit.data.sql_alchemy import SQLAlchemyDataLayer

@cl.data_layer
def get_data_layer():
    return SQLAlchemyDataLayer(conninfo="...")

Custom data layers

Follow the reference for an exhaustive list of the methods your custom data layer needs to implement.