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

[Bug fix] Fix issue for using any metadata db apart from sqlite #1282

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

deshraj
Copy link
Collaborator

@deshraj deshraj commented Feb 22, 2024

Description

Forgot to remove the sqlite specific args when making connection for the metadata sql database. Fixed the issue in this PR.

Now, users can try any sql database as their metadata database which stores the chat history and data sources added to their apps.

Example

  1. Start postgres db using following command using docker:
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
  1. Now, run embedchain app that uses the created database and stores information there:
import os
from embedchain import App

os.environ["EMBEDCHAIN_DB_URI"] = "postgresql://postgres:mysecretpassword@localhost:5432/postgres"
app = App()
app.add("https://www.forbes.com/profile/elon-musk")
answer = app.chat("What is the net worth of Elon Musk?")
print(answer)
  1. Once done, you can check the data by going into psql console and see the data:
$ docker exec -it some-postgres psql -U postgres

postgres=# \d
 public | alembic_version | table | postgres
 public | ec_chat_history | table | postgres
 public | ec_data_sources | table | postgres

postgres=# \d ec_chat_history
 app_id     | character varying           |           | not null |
 id         | character varying           |           | not null |
 session_id | character varying           |           | not null |
 question   | text                        |           |          |
 answer     | text                        |           |          |
 metadata   | text                        |           |          |
 created_at | timestamp without time zone |           |          |

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 22, 2024
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f0400e9) 56.75% compared to head (b24c906) 56.77%.

Files Patch % Lines
embedchain/core/db/database.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1282      +/-   ##
==========================================
+ Coverage   56.75%   56.77%   +0.01%     
==========================================
  Files         150      150              
  Lines        6066     6071       +5     
==========================================
+ Hits         3443     3447       +4     
- Misses       2623     2624       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@deshraj deshraj merged commit b4bb4cf into main Feb 22, 2024
5 checks passed
@deshraj deshraj deleted the user/dyadav/bug-fix-postgres-db-support branch February 22, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant