TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Inline SQL in any Python program

26 点作者 ekzhang超过 2 年前

6 条评论

pizza超过 2 年前
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 未加载
rubenfiszel超过 2 年前
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 未加载
orf超过 2 年前
Looks really interesting, but why overload the ^ operator? Is a function call <i>really</i> that much more verbose?
评论 #33135352 未加载
rubenfiszel超过 2 年前
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 未加载
lazzlazzlazz超过 2 年前
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.
biggerChris超过 2 年前
Python and Haskell programmers at this point are just bored. All python and Haskell programmers need to start being developers.
评论 #33136677 未加载