TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Inline SQL in any Python program

26 pointsby ekzhangover 2 years ago

6 comments

pizzaover 2 years ago
This is awesome. Is there a way to get it to work with e.g. dataclasses-sql? I am thinking of something such as<p><pre><code> stuff: list[mydataclass] sql_val^ &quot;select * from stuff where stuff.field = 2&quot; </code></pre> over any kind of &#x27;fmappable&#x27; container; perhaps eg.<p><pre><code> stuff: dict[int, mydataclass] stuff2: dict[int, mydataclass] sql_val^ &quot;select (s2.val, s.key) from stuff as s, stuff2 as s2 where s.key &gt; s2.key and s2.value != s.value)&quot; </code></pre> etc
评论 #33137999 未加载
rubenfiszelover 2 years ago
Very cool, I have lots of ideas of how to leverage it for windmill.dev. We were using psycopg2 for all our examples but this is much cleaner. Thanks for sharing!
评论 #33135379 未加载
orfover 2 years ago
Looks really interesting, but why overload the ^ operator? Is a function call <i>really</i> that much more verbose?
评论 #33135352 未加载
rubenfiszelover 2 years ago
Something was not clear to me from the README. When you do string interpolations as in your examples, those are actually prepared sql statements right ? Otherwise it would open the way for sql injections.
评论 #33135606 未加载
lazzlazzlazzover 2 years ago
This is great. I have a personal-use version of this (also using DuckDB&#x27;s fantastic Pandas compatibility) and will see if I can just switch over.
biggerChrisover 2 years ago
Python and Haskell programmers at this point are just bored. All python and Haskell programmers need to start being developers.
评论 #33136677 未加载