I built a 57-line asyncpg wrapper because SQLAlchemy was driving me insane
The developer, frustrated with SQLAlchemy's complexity in Python, created a minimal asyncpg wrapper called EzQL that allows writing raw SQL while getting typed Pydantic models back. EzQL avoids ORM abstractions, focusing on simplicity, transparency, and type safety with explicit queries. It includes a CLI tool to validate models against the database schema before deployment.
- ▪The author built EzQL as a 57-line wrapper around asyncpg to avoid SQLAlchemy's complexity and hidden query behavior.
- ▪EzQL allows developers to write raw SQL and map results to Pydantic models, supporting both table models and DTOs for joins.
- ▪A built-in CLI tool validates model-to-database schema alignment, catching type mismatches and missing columns before production deployment.
- ▪EzQL avoids ORM features like sessions, lazy loading, and automatic relationship handling, promoting direct and predictable database interactions.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3908416) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } kernz Posted on May 2 I built a 57-line asyncpg wrapper because SQLAlchemy was driving me insane #sql #python #sqlalchemy #postgres I came from Rust where I used sqlx — you write raw SQL, you get typed structs back. Simple, honest, fast. Then I had to write Python and reached for SQLAlchemy. Big mistake. Suddenly I was learning a DSL on top of SQL. Debugging what ORM decided to generate behind my back. Fighting N+1 queries I didn't even know were happening.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).