langchain icon indicating copy to clipboard operation
langchain copied to clipboard

DatabaseChain not working on version 0.0.158 for SQLLite

Open vermion opened this issue 1 year ago • 5 comments

System Info

Python 3.10 0.0.158 Tried to upgrade Langchain to latest version and the SQLChain no longer works Looks like the latest version has changed the way SQL chains are initialized.

Who can help?

No response

Information

  • [ ] The official example notebooks/scripts
  • [ ] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

For version 0.0.158 the way SQL chains are initialized has changed, but the dicumentation has not been updated db_chain = SQLDatabaseChain.from_llm(llmChat, db)

The above code throws the following error: (<class 'ImportError'>, ImportError("cannot import name 'CursorResult' from 'sqlalchemy' (C:\Projects\llmsql\lib\site-packages\sqlalchemy\init.py)"), <traceback object at 0x0000026D7EDC4680>)

Expected behavior

Should just work as before.

vermion avatar May 05 '23 13:05 vermion

SQLAlchemy no longer works on v1.x. CursorResult is in v2.

bmanturner avatar May 05 '23 13:05 bmanturner

So for now it is just broken? Is there anything I can do to fix this it?

vermion avatar May 05 '23 14:05 vermion

You can update SQLAlchemy. I was surprised they broke compatibility with v1 so quickly after supporting v2; maybe it wasn't intentional

bmanturner avatar May 05 '23 14:05 bmanturner

Updating SQLALchemy to 2.0.12 works for me

Buckler89 avatar May 05 '23 14:05 Buckler89

Ok thanks

vermion avatar May 05 '23 14:05 vermion

Hi, @vermion! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you reported an issue stating that SQLChain was not working on version 0.0.158 for SQLLite. bmanturner commented that SQLAlchemy no longer works on v1.x and suggested updating to version 2. Buckler89 confirmed that updating SQLAlchemy to version 2.0.12 resolved the issue. It seems like the problem has been resolved.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!

dosubot[bot] avatar Sep 12 '23 16:09 dosubot[bot]