Skip to content

psycopg module version error #94

@erangalds

Description

@erangalds

I was trying out langchain_postgres module today. I was using the PostgresChatMessageHistory function. I started to get below error when I used the example code given in the README file.

Traceback (most recent call last):
File "/home/eranga/learn/learn-langgraph/brandon-labs/chat_models/02_chat_model_conversation_bot.py", line 44, in
PostgresChatMessageHistory.create_tables(sync_connection, chat_history_table_name)
File "/home/eranga/learn/learn-langgraph/langgraph-env/lib/python3.12/site-packages/langchain_postgres/chat_message_histories.py", line 218, in create_tables
cursor.execute(query)
TypeError: argument 1 must be a string or unicode object: got Composed instead

Then I looked at the modules which threw the error. It was basically saying the cursor.execute(qurey) was expecting a string. Then I looked at the module functions then noticed that the imported library was psycopg. Then I manually changed that to psycopg2. Then the program worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions