Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
| Memory | N/A | ✅ | ✅ | Fast in-memory storage for development and caching |
| Disk | Stable | ☑️ | ✅ | Persistent file-based storage in a single file |
| Disk (Per-Collection) | Stable | ☑️ | ✅ | Persistent storage with separate files per collection |
| DuckDB | Unstable | ☑️ | ✅ | In-process SQL OLAP database with native JSON storage |
| FileTree (test) | Unstable | ☑️ | ✅ | Directory-based storage with JSON files for visual inspection |
| Null (test) | N/A | ✅ | ✅ | No-op store for testing without side effects |
| RocksDB | Unstable | ☑️ | ✅ | High-performance embedded database |
Expand Down Expand Up @@ -400,6 +401,7 @@
| Elasticsearch | Unstable | ✅ | ✅ | Full-text search with key-value capabilities |
| Memcached | Unstable | ✅ | ✖️ | High-performance distributed memory cache |
| MongoDB | Unstable | ✅ | ✅ | Document database used as key-value store |
| PostgreSQL | Unstable | ✅ | ✖️ | PostgreSQL database with JSONB storage |
| Redis | Stable | ✅ | ✅ | Popular in-memory data structure store |
| Valkey | Stable | ✅ | ✅ | Open-source Redis fork |

Expand Down Expand Up @@ -569,6 +571,55 @@

---

### PostgreSQLStore

PostgreSQL database with JSONB storage for flexible key-value data.

**Note:** PostgreSQL is async-only. This store uses `asyncpg` which provides native async/await operations.

Check failure on line 578 in docs/stores.md

View workflow job for this annotation

GitHub Actions / markdown_lint

Line length

docs/stores.md:578:81 MD013/line-length Line length [Expected: 80; Actual: 107] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md013.md
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

```python
from key_value.aio.stores.postgresql import PostgreSQLStore

# Using connection URL
store = PostgreSQLStore(url="postgresql://localhost:5432/mydb")

# Using connection parameters
store = PostgreSQLStore(
host="localhost",
port=5432,
database="mydb",
user="myuser",
password="mypass"
)

async with store:
await store.put(key="user_1", value={"name": "Alice"}, collection="users")
user = await store.get(key="user_1", collection="users")
```

**Installation:**

```bash
pip install py-key-value-aio[postgresql]
```

**Use Cases:**

- Applications already using PostgreSQL
- Need for SQL querying on stored data
- ACID transaction requirements
- Complex data relationships

**Characteristics:**

- JSONB storage for efficient querying
- TTL support via expiration timestamps
- Single table design (collections as column values)
- Async-only (uses asyncpg)
- Stable storage format: **Unstable**

---

### MemcachedStore

High-performance distributed memory caching system.
Expand Down
3 changes: 2 additions & 1 deletion key-value/key-value-aio/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rocksdb = [
"rocksdict>=0.3.2 ; python_version < '3.12'"
]
duckdb = ["duckdb>=1.1.1", "pytz>=2025.2"]
postgresql = ["asyncpg>=0.30.0"]
wrappers-encryption = ["cryptography>=45.0.0"]

[tool.pytest.ini_options]
Expand All @@ -70,7 +71,7 @@ env_files = [".env"]

[dependency-groups]
dev = [
"py-key-value-aio[memory,disk,filetree,redis,elasticsearch,memcached,mongodb,vault,dynamodb,rocksdb,duckdb]",
"py-key-value-aio[memory,disk,filetree,redis,elasticsearch,memcached,mongodb,vault,dynamodb,rocksdb,duckdb,postgresql]",
"py-key-value-aio[valkey]; platform_system != 'Windows'",
"py-key-value-aio[keyring]",
"py-key-value-aio[pydantic]",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""PostgreSQL store for py-key-value-aio."""

try:
from key_value.aio.stores.postgresql.store import PostgreSQLStore
except ImportError as e:
msg = 'PostgreSQLStore requires the "postgresql" extra. Install via: pip install "py-key-value-aio[postgresql]"'
raise ImportError(msg) from e
Comment thread
coderabbitai[bot] marked this conversation as resolved.

__all__ = ["PostgreSQLStore"]
Loading
Loading