4 ms·
Here is my rather naive take on the same subject. But I had a very different motivation than the author. See I actually quite like SQL and enjoy programming in
by somat 11mo ago
Here is my rather naive take on the same subject. But I had a very different motivation than the author. See I actually quite like SQL and enjoy programming in it, but what I don't like is mixing sql and python. So one night in a flash of inspiration or perhaps a fever dream I wrote this thing that lets you have stand alone parameterized sql queries and you call them like a python function or generator. It is one of those overly clever things where I sort of hate the magic, but I find myself using it more and more which I will probably regret one day.
https://nl1.outband.net/fossil/query/file?name=query.py&ci=tip https://nl1.outband.net/fossil/query/file?name=query.py&ci=t...
In short you have your query in file sql/dept_personal.sql and you call it like
for row in q.dept_personal(db_cursor, department='manpower'):
- digdugdirk 11mo agoI honestly have no opinion in this discussion, but I will 100% upvote the first Fossil repository I've seen shared on here! How do you find developing on the Fossil platform?
- somat 11mo agoIt has a sane ui/syntax, all the additional infrastructure you might want is built in (webpage, wiki, forum, tickets) and is trivial to set up. It is nearly the perfect version control system. Especially for the small independent amateur developer.
- digdugdirk 11mo agoAwesome. Does it have any sort of CI/CD capabilities? And do you have any recommendations for learning resources for someone to get started?
- somat 11mo agoFor getting started there is the quick start guide https://fossil-scm.org/home/doc/trunk/www/quickstart.wiki https://fossil-scm.org/home/doc/trunk/www/quickstart.wiki and after that the built in help gets you pretty far. Really, most distributed version control systems have the same workflow the devil is in the exact syntax used. As for CI there are pre-commit hooks I suspect could be used for that process. https://fossil-scm.org/home/help/hook https://fossil-scm.org/home/help/hook and https://fossil-scm.org/home/doc/trunk/www/hooks.md https://fossil-scm.org/home/doc/trunk/www/hooks.md
- truculent 11mo agoYou may enjoy https://pugsql.org https://pugsql.org
- getnormality 11mo agoThis is a nice package, and a great illustration of how languages other than R suffer from the lack of an aesthetically elegant way to select list elements with bare words, like R's $ operator. Because their lists don't have selection by bare words, they have to go one of several other specialized, distinct, built-in Abstract Data Types to get it. They have to create whole so-called "Classes" and "Modules", when all they really needed was a list whose elements can be accessed with a dot and a bare word. The pandas package for tabular data manipulation requires even more complicated workarounds. It has a DataFrame Class composed of objects of Column Class. Then it makes an arbitrary bunch of common functions, so common that many are built into Python itself, Methods of said Columns. (In R, a table is just a list of vectors, and no Methods are needed.) So now you've got a thing that's supposedly a real Class, but it's really just a container of completely arbitrary fields and data types. These fields are themselves instances of another Class that is supposedly specific to pandas, but is really just a vector, and a vector doesn't necessarily have anything to do with being part of a table. And that Class has some random methods that give you additional ways to do basic things the language already does, and are often not the functions you actually need to work with the data therein. All that just so that we can write stuff like df.col.max(), and... gosh, what is that even supposed to mean? Can we all just admit that we like writing code in chains separated by dots, and stop tying that capability to hierarchies of Official Abstract Data Types? These non-R languages make you utter such strange incantations just to put something in a key-value container and access that thing with nice-looking code. I feel like this makes it harder to realize that very often this is the best way of doing things. R has a bit more varied and sometimes mildly ugly syntax than other languages, but once you get used to the building blocks it gives you, it has all these powers to do very dynamic things in very easy ways, without a bunch of ponderous specialized concepts.
- getnormality 11mo agoCorrection, the Column object is called Series, but the same points apply.
- atombender 11mo agoThat's basically the idea behind Sqlc [1]. By letting SQL be SQL, you avoid the many awkward mechanisms ORMs need to integrate SQLisms into the native language, and you define the query only in terms of its inputs and outputs, which can be made type-safe since they're declaratively defined. The downside is that parameterized queries are a bit of a chore; for example, if a query should support an optional filter on user_id, you need to craft it like this: WHERE ... AND CASE WHEN sqlc.narg('user_id') IS NOT NULL THEN sqlc.narg('user_id') ELSE true END This is not too bad, though, and the conditionals get optimized away by the database planner. [1] https://sqlc.dev/ https://sqlc.dev/