Find answers from the community

Home
Members
eren_yeager
e
eren_yeager
Offline, last seen 3 months ago
Joined September 25, 2024
Hi, I am new to this and am trying to use Llamaindex to connect the MySQL database (80 tables) with the LLM(gpt-3.5-turbo) and used NLSQLRetriever-Text-to-SQL Retriever and developed a chatbot using Streamlit. My problem is that it is retrieving the proper responses often like invalid SQL query and so on. Can anyone help me with this, please?
2 comments
W
from llama_index.readers.database import DatabaseReader

reader = DatabaseReader(
scheme=os.getenv("mysql"),
host=os.getenv("localhost"),
port=os.getenv("3306"),
user=os.getenv("root"),
password=os.getenv("password"),
dbname=os.getenv("databasename"),
)

query = "SELECT * FROM users"
documents = reader.load_data(query=query)

Can anyone help me with the error?

ValueError Traceback (most recent call last)
Cell In[52], line 5
1 from llama_index.core import download_loader
3 from llama_index.readers.database import DatabaseReader
----> 5 reader = DatabaseReader(
6 scheme=os.getenv("mysql"),
7 host=os.getenv("localhost"),
8 port=os.getenv("3306"),
9 user=os.getenv("root"),
10 password=os.getenv("password"),
11 dbname=os.getenv("databasename"),
12 )
14 query = "SELECT * FROM users"
15 documents = reader.load_data(query=query)

File ~\anaconda\lib\site-packages\llama_index\readers\database\base.py:70, in DatabaseReader.init(self, sql_database, engine, uri, scheme, host, port, user, password, dbname, *args, kwargs) 68 self.sql_database = SQLDatabase.from_uri(uri, *args, kwargs)
69 else:
---> 70 raise ValueError(
71 "You must provide either a SQLDatabase, "
72 "a SQL Alchemy Engine, a valid connection URI, or a valid "
73 "set of credentials."
74 )

ValueError: You must provide either a SQLDatabase, a SQL Alchemy Engine, a valid connection URI, or a valid set of credentials.
2 comments
W