Having problems with Langchain and SQLDatabaseToolkit: 'sql_db_list_tables' and others doesn't work #23724
Replies: 1 comment
-
Hello, @arturgomesc! I'm here to assist you with any bugs, questions, or contributions you may have. Let's work together to resolve the issue you're facing. The issue you're encountering with On the other hand, Here is a relevant code snippet showing how table reflection is handled: self._metadata.reflect(
views=view_support,
bind=self._engine,
only=list(self._usable_tables),
schema=self._schema,
) If the reflection process fails, it can cause methods like Additionally, the To resolve this, you might need to ensure that your MySQL user has the necessary permissions to access metadata. You can try granting the required permissions: GRANT SHOW DATABASES, SHOW TABLES, SHOW COLUMNS ON db_freterapid2.* TO 'your_user'@'your_host'; After granting the permissions, try running your code again. If the issue persists, you might need to check for any specific configurations or limitations in your MySQL setup that could be affecting the reflection process. For more details, you can refer to the relevant source code in Langchain: |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Hello, everyone. I'm trying to query a MySQL database using Python and Langchain. However, some features seem to return nothing, while others work. sql_db_list_tables, get,usable_table_names, table_info and others do not work, while other features like sql_db_query work. I've tried the same code with a postgresql database with read and write permissions and I didn´t get this trouble, just worked fine. This MySQL databse just have the read permissions.
Does anyone know what the problem could be?
I tried to make my database schema explicit, updated the libraries, but nothing helped.
System Info
pip install langchain==2.6.0
Beta Was this translation helpful? Give feedback.
All reactions