# PostgresChatMessageHistory

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/chat_message_histories/postgres/PostgresChatMessageHistory)

Chat message history stored in a Postgres database.

**DEPRECATED**: This class is deprecated and will be removed in a future version.

Use the `PostgresChatMessageHistory` implementation in `langchain_postgres`.

## Signature

```python
PostgresChatMessageHistory(
    self,
    session_id: str,
    connection_string: str = DEFAULT_CONNECTION_STRING,
    table_name: str = 'message_store',
)
```

## Extends

- `BaseChatMessageHistory`

## Constructors

```python
__init__(
    self,
    session_id: str,
    connection_string: str = DEFAULT_CONNECTION_STRING,
    table_name: str = 'message_store',
)
```

| Name | Type |
|------|------|
| `session_id` | `str` |
| `connection_string` | `str` |
| `table_name` | `str` |


## Properties

- `connection`
- `cursor`
- `session_id`
- `table_name`
- `messages`

## Methods

- [`add_message()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/postgres/PostgresChatMessageHistory/add_message)
- [`clear()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/postgres/PostgresChatMessageHistory/clear)

## ⚠️ Deprecated

Deprecated since version 0.0.31.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/d5ea8358933260ad48dd31f7f8076555c7b4885a/libs/community/langchain_community/chat_message_histories/postgres.py#L18)