SQLDatabase.from_uri Takes long time and we need to connect to database dynamically #25807
Unanswered
sanket20138339
asked this question in
Q&A
Replies: 1 comment
-
I don't fully understand your final question, but if you are looking to manage/store context of a db using SQLDatabase you could use: db = SQLDatabase.from_uri(connection_string)
context = db.get_context()
table_info = context['table_info']
table_names = ['table_names'] Where you could then pass those as prompt variables and set up a different connection with the same context, if that's what you are looking for. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
We are using the LangChain SQL agent and it is working perfectly fine.
The only thing is SQLDatabase.from_uri it takes a long time as I understand it reads all schema and everything that is required for an agent.
We have a multi-tenant system that has multiple DBs and all DBs have the same structure.
but depending on the logged-in user I need to connect to the that tenant's DB but i use SQLDatabase.from_uri(connection_string) it will take a long time.
is there a way to change the connection string for SQLdatabase once the schema is read? so it will be faster
System Info
langchain==0.2.11
langchain-community==0.2.10
langchain-core==0.2.23
langchain-openai==0.1.17
langchain-text-splitters==0.2.2
langsmith==0.1.93
Beta Was this translation helpful? Give feedback.
All reactions