Menu

1 / 2

I built a tiny Python library that turns method names into SQL queries

DEV Community: database·Kamyar Inanloo·5 months ago
#15i4asTz
#dev#status#simple#select#users
Reading 0:00
15s threshold

I’ve been working on a small library called guess-what. The idea is simple: instead of writing boilerplate CRUD queries or repository methods, you call semantic method names and the library turns them into SQL.

For example:

db.get_user_by_id(123)

SELECT * FROM users WHERE id = ?

db.get_user_columns_name_and_email_by_status(status="active")

SELECT name,email FROM users WHERE status = ?

db.add_user(user={"name": "Alice", "email": " [email protected] ", "status": "active"})

INSERT INTO users (name,email,status) VALUES (?, ?, ?)

It supports:

sync and async database connections

keyword arguments

dataclasses

Pydantic models

dict-based reads/writes

simple dynamic SELECT / INSERT / UPDATE / DELETE

stored procedure/function calls with call_...

I’m intentionally not trying to build a full ORM like SQLAlchemy, Django ORM, or PonyORM.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.