---
title: "coddpiece: Watch Relational Algebra Become SQL"
url: https://daily.dev/posts/coddpiece-watch-relational-algebra-become-sql-obultvmjj
source_url: https://postgr.es/p/9nr
type: article
source: "Planet PostgreSQL"
published: 2026-06-26T16:03:26.877Z
updated: 2026-06-27T08:19:44.887Z
tags: ["python", "backend", "sql", "postgresql"]
reading_time: 3
upvotes: 2
comments: 0
language: en
---

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

# coddpiece: Watch Relational Algebra Become SQL

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 3 min read · 2 upvotes · 0 comments

## Summary

coddpiece is a Python library that teaches relational algebra by letting you build expressions via method chaining, then compiles them to real SQL and runs them on any DB-API 2.0 connection. The core value is the side-by-side view: every expression can call .explain() to show the algebra notation, expression tree, compiled SQL, and plain-English reading simultaneously. This makes abstract concepts like relational division — which compiles to a notoriously ugly double-negation NOT EXISTS/EXCEPT pattern — suddenly click. The library enforces set semantics with DISTINCT by default (matching the relational model), offers a .bags() mode to expose the SQL/theory gap, and ships with the classic suppliers-and-parts dataset. It supports SQLite, PostgreSQL, and MySQL, though only the SQLite path is CI-tested against a live database. Install via pip, requires Python 3.10+, MIT licensed.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9nr>

## Similar posts on daily.dev

- [Things I want in a modern relational query language](https://daily.dev/posts/things-i-want-in-a-modern-relational-query-language-y0qgepv3u) · Lobsters · 0 upvotes · 0 comments
- [Arrows to Arrows, Categories to Queries :: Reasonably Polymorphic](https://daily.dev/posts/arrows-to-arrows-categories-to-queries-reasonably-polymorphic-6cvvcofvh) · Planet Haskell · 0 upvotes · 0 comments
- [SQL vs. Python: Frenemies of the Data World](https://daily.dev/posts/sql-vs-python-frenemies-of-the-data-world-yntxm6vg6) · The New Stack · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#backend](https://daily.dev/tags/backend), [#sql](https://daily.dev/tags/sql), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/coddpiece-watch-relational-algebra-become-sql-obultvmjj)
