Reputation: 93
I am following langchain
quick start: https://python.langchain.com/docs/use_cases/sql/quickstart/
Below is the code snippit:
import getpass
import os
from langchain_community.utilities import SQLDatabase
from langchain.chains import create_sql_query_chain
from langchain_openai import ChatOpenAI
os.environ["OPENAI_API_KEY"] = getpass.getpass()
db = SQLDatabase.from_uri("postgresql://xxx:xxx:5432/xxx")
print("db.dialect : ", db.dialect)
print("db.get_usable_table_names() : " , db.get_usable_table_names())
the above is code is working, my issue is for the db.get_usable_table_names()
function call, its not returning all the tables from my database.
Do we have any inside what's the reason and how can we ensure we can get all the tables?
Upvotes: 0
Views: 501
Reputation: 534
In my case, the problem was that I specified postgres
db in the end of the connection string instead of the actual db I needed. Hopefully, it'll help somebody.
Upvotes: 0