Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SQLite for custom data layer #832

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

tjroamer
Copy link

@tjroamer tjroamer commented Mar 20, 2024

Overview

How to configure

import chainlit.data as cl_data
from chainlit.data.sqlite import SQLiteDataLayer

# a default database file chainlit.db will be created in the working dir
cl_data._data_layer = SQLiteDataLayer()

# Or optionally provide own file (can be relative or absolute) as the init parameter
# this code will create C:/myfolder if it doesn't exist, and data is persited in mydata.db
cl_data._data_layer = SQLiteDataLayer(db_filepath="C:/myfolder/mydata.db")

Test

A simple sanity check is implemented in cypress/e2e/data_layer_sqlite, which is a simplified copy of cypress/e2e/data_layer.

Limitation

no file blob support, so chat history will not show attachments

@Rajatkhanna801
Copy link

Hi @tjroamer
I want to know If I want to create separate sqlite database for each user how I can do that.

@tjroamer
Copy link
Author

Hi @tjroamer I want to know If I want to create separate sqlite database for each user how I can do that.

With the current chainlit data layer, user-specific sqlite database might not be straightforward to implement. One solution I can think of is that you create views for different users, and select only rows that relevant to that user. This would require some post-processing steps once you have the database as a single file.

@Rajatkhanna801
Copy link

@tjroamer
Actually as per my requirement I want separate sqlite database for each user and I think we can achieve that with sending custom database url.

@tjroamer
Copy link
Author

Will these users use the same chatbot based on the same server? If this is the case, you cannot send custom database url for each user, since the database url is a server-side setting, and it is done only once when the server starts.

@Rajatkhanna801
Copy link

okay let me figure another way for that.

@Rajatkhanna801
Copy link

@tjroamer
I have configured Microsoft authentication and everytime new user logged in I am creating new database sqlite file.

But I am not sure how I can put data in that tables for specific user.

Kai Liu added 3 commits March 20, 2024 20:55
- hide the protocol sqlite+aiosqlite:/// under the hood
- user can use relative or absolute file path as input
@intc-hharshtk
Copy link

I just see this when I load old thread How to fix it
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants