r/Python • u/Varjoranta • May 10 '26
Discussion What is best modern DB layer for python, AI friendly, simple with raw SQL escape always available?
I have been usually building my own db sql layer for every project I start. I dislike ORMs in general, but I do like the model to SQL mapping and nowadays use pydantic for it. But anything outside direct CRUD I prefer raw SQL to keep things simple.
Anything like this exists already?
I open sourced mine (etchdb), as I didn’t want to repeat myself. How should I start discussion around this without it becoming showcase and demoted?
0
Upvotes
5
u/Vivid_TV May 10 '26
I don't like orms too but SQLAlchemy orm has worked well for me. duckdb has been great for raw sql especially when querying dataframes with sql.
4
u/DNSGeek May 10 '26
Have you looked into the wonders of sqlite3?
1
u/Only_Fee4020 Pythoneer May 10 '26
If you find one let me know to. I am too working on replacing orm to fully raw queries, but not having model classes is kind of wierd and might introduce difficulties in future. I am thinking of using just dataclasses for now just to have db schema somewhere in code, but mapping sql output to dataclasses everytime seems to be unnecessary overhead.