How to use `geoalchemy2` with langchain and SQLAlchemy?

  Kiến thức lập trình

I’m new to python, and I’m trying to accomplish a small POC with langchain.

I’m building this RAG application with langchain and pyhton. I’m trying to connect with a MySQL database using the following code:

import os
from langchain_community.utilities import SQLDatabase

database_user = os.environ['DATABASE_USER']
database_password = os.environ['DATABASE_PASSWORD']
database_host = os.environ['DATABASE_HOST']
database_port = os.environ['DATABASE_PORT']
database_name = os.environ['DATABASE_NAME']

db = SQLDatabase.from_uri(f'mysql+mysqlconnector://{database_user}:{database_password}@{database_host}:{database_port}/{database_name}')

schema = db.get_table_info(table_names=['<table_name>'])

The connection works, and when I printed the result of schema it has the expected value. Therefore, I’m getting the following warning in the terminal:

C:<path_to_project>.venvLibsite-packageslangchain_communityutilitiessql_database.py:122: 
  SAWarning: Did not recognize type 'geometry' of column '<table_column>'

I have tried everything that I’ve found online, but I couldn’t fix the warning. I have tried importing the geoalchemy2 libraby, but it didn’t did the trick. I think that it because the SQLAlchemy code is wrapped by the SQLDatabase class from langchain_community.utilities.

How can I get rid of this warning? Is it possible to fix it?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT