> ## Documentation Index
> Fetch the complete documentation index at: https://askmarvin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# postgres

# `marvin.memory.providers.postgres`

## Classes

### `PostgresMemory`

```python theme={null}
class PostgresMemory()
```

An async MemoryProvider storing text + embeddings in PostgreSQL
using SQLAlchemy + pg\_vector, but with full async support.

**Methods:**

* **`add`**
  ```python theme={null}
  async def add(self, memory_key: str, content: str) -> str
  ```
  Insert a new record with an embedding vector.
  Returns the inserted record's UUID.
* **`configure`**
  ```python theme={null}
  async def configure(self, memory_key: str)
  ```
  1. Create an async engine.
  2. Optionally create the DB if it doesn't exist (requires sync workaround).
  3. Install pgvector extension.
  4. Generate the memory table if missing.
  5. Initialize the async sessionmaker.
* **`delete`**
  ```python theme={null}
  async def delete(self, memory_key: str, memory_id: str)
  ```
  Delete a record by UUID.
* **`search`**
  ```python theme={null}
  async def search(self, memory_key: str, query: str, n: int = 20) -> Dict[str, str]
  ```
  Async nearest-neighbor search via pgvector \<-> operator or .l2\_distance(),
  returning up to N results as \{id: text}.

### `SQLMemoryTable`

```python theme={null}
class SQLMemoryTable()
```

A simple declarative model that represents a memory record.

We'll dynamically set the **tablename** at runtime.

***

**Parent Module:** [`providers`](marvin-memory-providers)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.