Re:Show HN: Inline SQL in any Python program
by pizza on Saturday October 08, 2022 @06:35PM
(#33136682)
This is awesome. Is there a way to get it to work with e.g. dataclasses-sql? I am thinking of something such as
over any kind of 'fmappable' container; perhaps eg.
etc
[ Parent
| on HN ]
Re:Show HN: Inline SQL in any Python program
by ekzhang on Saturday October 08, 2022 @11:20PM
(#33137999)
Hm, you're currently able to do this through Pandas.
stuff: list[mydataclass]
stuff_df = pd.DataFrame(stuff)
results = sql^ "SELECT * FROM stuff_df WHERE field = 2"
My guess is that this would be a lot faster than dataclasses-sql due to less conversion overhead, but we'd have to benchmark it to be sure.
Re:Show HN: Inline SQL in any Python program
by pizza on Tuesday October 11, 2022 @02:15PM
(#33166880)
Ah interesting. I was thinking along the lines of if you wanted to, say, package up an algorithm as a class, make a ton of these classes/algorithms, and then affix them in a bunch of ways. E.g. "find the algorithms that take in data and spit out predictions, compose them with the algorithms that have a prediction_input field" etc.