Metadata-Version: 2.5
Name: caddix
Version: 1.2.0
Summary: Caddix is a helper library for Python designed to make working with PostgreSQL databases easier, faster, and safer.
Project-URL: Homepage, https://github.com/MarcusGros/caddix
Project-URL: Repository, https://github.com/MarcusGros/caddix
Project-URL: Documentation, https://github.com/MarcusGros/caddix#readme
Project-URL: Bug Tracker, https://github.com/MarcusGros/caddix/issues
Author-email: Marcus Gros <marcus-gros@freenet.de>
License: MIT License
        
        Copyright (c) 2026 Marcus Gros
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: connection-pool,database,orm-alternative,postgresql,psycopg,sql
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: psycopg[binary]>=3.1.0
Provides-Extra: c
Requires-Dist: psycopg[c]>=3.1.0; extra == 'c'
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/MarcusGros/caddix/main/caddix.jpeg" alt="Caddix Logo" width="320" />
</p>

# Caddix - PostgreSQL Connection Assistant 

**Caddix** is a lightweight, high-performance Python helper library built on top of [psycopg 3](https://www.psycopg.org/psycopg3/docs/) designed to make interacting with PostgreSQL databases easier, faster, and safer.

---

## 🚀 Key Features & Advantages

- **Boilerplate-Free CRUD**: High-level Python methods for querying, inserting, updating, and deleting rows without writing raw SQL strings for simple tasks.
- **Built-in Connection Pooling**: Thread-safe pool that reuses open connections. On reuse it discards closed, broken or expired (`ttl`) connections and opens new ones as needed; optional `pre_ping` detects connections the server has closed.
- **Transaction Safety (Rollback-by-Default)**: Sessions automatically roll back uncommitted changes when exiting context manager blocks or on unhandled exceptions.
- **Accident Protection**: `update()` and `delete()` without WHERE filters refuse to run unless you pass `allow_all=True`.
- **SQL-Injection Safe**: Secure SQL generation using `psycopg.sql.Identifier` and strict parameter binding.
- **Blazing Fast Mass Ingestion**: `insert_batch` leverages native PostgreSQL `COPY FROM STDIN` streaming for inserting thousands of records in milliseconds.
- **Rich Row Factories**: Easily map rows to Python `dict`, `tuple`, `namedtuple`, or custom `@dataclass` objects.
- **Keyword-Friendly**: Automatically handles Python reserved words in column names (e.g. `_from`, `_class`, `_import`).

---

## 📦 Installation & Requirements

Caddix requires **Python 3.10+**. The database driver **psycopg (version 3.x)** is automatically installed as a core dependency.

### Using `pip`

```bash
pip install caddix
```

### Using `uv` (Recommended)

```bash
uv add caddix
```

> 💡 **Performance Note**: For optimal performance without needing a local C compiler, you can optionally install the pre-compiled binary PostgreSQL driver via `pip install "psycopg[binary]"` or `uv add "psycopg[binary]"`.

---

## ⚡ Quickstart Guide

Here is a 30-second quickstart demonstrating how simple it is to configure and use Caddix:

```python
import caddix

# 1. Configure the database connection
caddix.Setup(
    databasename='app_db',
    username='postgres',
    password='mysecretpassword',
    hostname='localhost',
    port=5432
)

# 2. Open a session and execute queries
with caddix.DatabaseSession() as db:
    # SQL-free query: fetches a single row as a dictionary
    user = db.select_one('users', id=1)
    print("User found:", user)

    # Insert a new record and commit
    db.insert('logs', message='User 1 logged in')
    db.commit()
```

---

## 📚 Documentation & Deep Dives

For in-depth guides, complete API listings, and developer documentation, explore our documentation suite:

- [**User Guide & Manual**](https://github.com/MarcusGros/caddix/blob/main/docs/USER_GUIDE.md): Comprehensive walkthrough covering configuration, connection pooling, transactions, raw SQL, CRUD helpers, bulk operations, stored procedures, and row factories.
- [**API Reference**](https://github.com/MarcusGros/caddix/blob/main/docs/API_REFERENCE.md): Full technical reference of all classes, methods, parameters, and exceptions.
- [**Architecture & Internals**](https://github.com/MarcusGros/caddix/blob/main/docs/ARCHITECTURE.md): Component mapping, lifecycle workflows, and security architecture.
- [**Developer & Contributor Guide**](https://github.com/MarcusGros/caddix/blob/main/docs/DEVELOPER_GUIDE.md): Setup instructions, testing guidelines, and conventions for contributors.
- [**Changelog**](https://github.com/MarcusGros/caddix/blob/main/CHANGELOG.md): Release history, breaking changes, and migration notes.

---

## 🧪 Testing

- The standard suite and four stress tests passed on Linux across all 15 combinations of Python 3.10–3.14 and PostgreSQL 16–18.
- Stress tests cover sequential and parallel CRUD, batch operations, SQL and fetch helpers, functions, procedures, metadata, transactions, error recovery and connection pool reuse.
- A Windows smoke test of version 1.1.1 (Windows 11, Python 3.12 and 3.14, PostgreSQL 18) passed 18 of 19 checks; the one failure was a pooled connection closed by the server, which `pre_ping=True` now handles.
- These tests do not cover every scenario, sustained load, multiple processes or macOS. See the [Developer Guide](https://github.com/MarcusGros/caddix/blob/main/docs/DEVELOPER_GUIDE.md) for results and limitations.

---

## 👤 Author & License

- **Author**: Marcus Gros
- **Copyright**: 2026 Marcus Gros
- **License**: [MIT](https://github.com/MarcusGros/caddix/blob/main/LICENSE)

Have fun building fast, secure PostgreSQL applications with **Caddix**! 🐘

---

<sub>*Logo AI-generated via <a href="https://perchance.org">perchance.org</a>*</sub>
