OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

LLM Azure Openai - Unable to connect to PostgreSQL DB

  • Thread starter Thread starter Mani
  • Start date Start date
M

Mani

Guest

I am using LLM in Azure OpenAI and trying to connect to my local instance of PostgreSQL. Getting error. The code and error are paste here. Help is much appreciated.​



Code:
#!pip install langchain psycopg2
#!pip install --upgrade langchain-experimental
from langchain.llms import OpenAI
from langchain.sql_database import SQLDatabase, SQLDatabaseChain

host = "localhost"
port = 5433  
database = "dvdrental"
user = "postgres"
password = "xxxxxxx"

db_conn = SQLDatabase(host, port, database, user, password)

db_chain = SQLDatabaseChain(db_conn)`


Code:
ImportError                               Traceback (most recent call last)
\<ipython-input-52-eb9cde349665\> in \<cell line: 4\>()
2 #!pip install --upgrade langchain-experimental
3 from langchain.llms import OpenAI
\----\> 4 from langchain.sql_database import SQLDatabase, SQLDatabaseChain
5
6 #host=localhost port=5433 dbname=dvdrental user=postgres password=xxxxxxx connect_timeout=10 sslmode=prefer

ImportError: cannot import name 'SQLDatabaseChain' from 'langchain.sql_database' (/usr/local/lib/python3.10/dist-packages/langchain
<h2>I am using LLM in Azure OpenAI and trying to connect to my local instance of PostgreSQL.
Getting error.
The code and error are paste here.
Help is much appreciated.</h2>
<hr />
<pre><code>#!pip install langchain psycopg2
#!pip install --upgrade langchain-experimental
from langchain.llms import OpenAI
from langchain.sql_database import SQLDatabase, SQLDatabaseChain

host = "localhost"
port = 5433
database = "dvdrental"
user = "postgres"
password = "xxxxxxx"

db_conn = SQLDatabase(host, port, database, user, password)

db_chain = SQLDatabaseChain(db_conn)`
</code></pre>
<hr />
<pre><code>
ImportError Traceback (most recent call last)
\<ipython-input-52-eb9cde349665\> in \<cell line: 4\>()
2 #!pip install --upgrade langchain-experimental
3 from langchain.llms import OpenAI
\----\> 4 from langchain.sql_database import SQLDatabase, SQLDatabaseChain
5
6 #host=localhost port=5433 dbname=dvdrental user=postgres password=xxxxxxx connect_timeout=10 sslmode=prefer

ImportError: cannot import name 'SQLDatabaseChain' from 'langchain.sql_database' (/usr/local/lib/python3.10/dist-packages/langchain
</code></pre>
Continue reading...
 

Latest posts

Top