langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
88.09k stars 13.78k forks source link

sqlalchemy.exc.NoSuchTableError: archivesparameter #22312

Open CodeDevMasterPro opened 3 weeks ago

CodeDevMasterPro commented 3 weeks ago

Checked other resources

Example Code

from langchain_community.utilities import SQLDatabase

db = SQLDatabase.from_uri(f"mysql+pymysql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}")

print("dialect:",db.dialect)
print("get_usable_table_names:",db.get_usable_table_names())

Error Message and Stack Trace (if applicable)

  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\util\deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\sql\schema.py", line 431, in __new__
    return cls._new(*args, **kw)
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\sql\schema.py", line 485, in _new
    with util.safe_reraise():
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\sql\schema.py", line 481, in _new
    table.__init__(name, metadata, *args, _no_init=False, **kw)
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\sql\schema.py", line 861, in __init__
    self._autoload(
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\sql\schema.py", line 893, in _autoload
    conn_insp.reflect_table(
  File "C:\Development\Anaconda3\envs\langchain\lib\site-packages\sqlalchemy\engine\reflection.py", line 1538, in reflect_table
    raise exc.NoSuchTableError(table_name)
sqlalchemy.exc.NoSuchTableError: archivesparameter

Description

1.There are two databases: DB1 and DB2. DB1 is a temporary test database and DB2 is a development database.


  1. DB1 as a test only a few tables, DB2 as the development of the use of about 1000 tables.
  2. Core: At the beginning, DB2 is used in LangChain for testing, and the problem occurs. When the new DB1 is created and DB1 is switched to be used at the same time, everything is executed normally.

System Info

Encountered this problem on both Window & Ubuntu.

1.Windows10 22H2 Python 3.10.14

This problem was encountered by langchain==0.1.7, upgraded to the latest, and the problem still exists.


# python -m langchain_core.sys_info

System Information

OS: Windows OS Version: 10.0.19045 Python Version: 3.10.14 | packaged by Anaconda, Inc. | (main, May 6 2024, 19:44:50) [MSC v.1916 64 bit (AMD64)]

Package Information

langchain_core: 0.2.1 langchain: 0.2.1 langchain_community: 0.2.1 langsmith: 0.1.54 langchain_experimental: 0.0.59 langchain_openai: 0.1.6 langchain_text_splitters: 0.2.0

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langgraph langserve


2.Ubuntu22.04 Python 3.10.14

python -m langchain_core.sys_info

System Information

OS: Linux OS Version: #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 Python Version: 3.10.14 (main, May 6 2024, 19:42:50) [GCC 11.2.0]

Package Information

langchain_core: 0.1.23 langchain: 0.1.7 langchain_community: 0.0.20 langsmith: 0.0.87

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langgraph langserve

keenborder786 commented 3 weeks ago

Can you please tell me the version of SQLAlchemy that you are using?

CodeDevMasterPro commented 3 weeks ago

您能告诉我您使用的 SQLAlchemy 的版本吗?

SQLAlchemy==2.0.30
CodeDevMasterPro commented 3 weeks ago

您能告诉我您使用的 SQLAlchemy 的版本吗?

For SQLAlchemy, tried multiple 2.x.x versions, as well as tried the last version of 1.x.x, and still had the problem. So, I think the odds are that it's not SQLAlchemy.