Hacker Newsnew | past | comments | ask | show | jobs | submit | pgjones's commentslogin

The `sql_context` feature is meant to protect against SQL injection. I think for your usecase you would need to supply all columns, but you could used nested t-strings included based on whatever logic you need.


Sorry that is a typo, I meant,

    with sql_context(columns={"x"}):


The presence of Absent removes the entire expression, and if that removal results in an empty clause (or group) it will remove that as well. For example if `a = Absent` `WHERE a = {a}` will remove everything, whereas `WHERE a = {a} AND b = {b}` will result in `WHERE b = {b}`.

> Do you support templating a sql tstring into an sql tstring for composition?

Yep


How do you know what the expression is though? Don’t you need to be parsing the SQL? If I have non standard SQL somewhere upstream in the text how does the parser cope?


It does parse the SQL. At the moment an expression is defined as all the text between the appropriate separators given the clause.


Thanks, do you have a reference for SQL grammar - I've had no success finding an official source.


Ibis has sqlglot for parsing and rewriting SQL query graphs; and there's sql-to-ibis: https://github.com/ibis-project/ibis/issues/9529

sqlglot: https://github.com/tobymao/sqlglot :

> SQLGlot is a no-dependency SQL parser, transpiler, optimizer, and engine [written in Python]. It can be used to format SQL or translate between 24 different dialects like DuckDB, Presto / Trino, Spark / Databricks, Snowflake, and BigQuery. It aims to read a wide variety of SQL inputs and output syntactically and semantically correct SQL in the targeted dialects.


You can google SQL grammar. But here is the 2025: https://standards.iso.org/iso-iec/9075/-2/ed-6/en/


Thank you! My Google foo did not find this.


Google search sucks really bad now for very specific searches.


If you want to see a usage for this I've built, and use, [SQL-tString](https://github.com/pgjones/sql-tstring) as an SQL builder.


Quart, the ASGI version of Flask, also has background tasks, https://quart.palletsprojects.com/en/latest/how_to_guides/ba..., and there is an extension Quart-Tasks, https://github.com/pgjones/quart-tasks, to run them on a schedule. Via

    @tasks.cron("*/5 * * * *")  # every 5 minutes
    async def infrequent_task():
        ...
In addition Hypercorn, https://github.com/pgjones/hypercorn, (a ASGI and WSGI) also does not use gunicorn, having migrated many years ago.


It is a shame GCRA is not more well known and used for rate limiting. It is, in my view, a better algorithm.

https://medium.com/smarkets/implementing-gcra-in-python-5df1... https://en.m.wikipedia.org/wiki/Generic_cell_rate_algorithm


Isn't GCRA a variant of leaky bucket, i.e. the token bucket described in the article?

As far as I can tell, the behavior should be the same, the difference is just implementation details and what you track.


If leaky bucket means "manages burst sizes and burst intervals" then yeah, they are similar in that regard but they do it differently. GCRA is more analogous to a traffic light where its solely time-based and there is no overhead needed to remove/add tokens so you are storing 1 less state object. For all purposes its probably a micro-optimization but being aware how GCRA works can yield less code but perhaps at the expense of obscurity of a lesser known algo.

I think you understand the differences but I think its improper to consider it a variant of leaky bucket as various resources refute


Yes, I've written about this comparison in detail https://pgjones.dev/blog/fastapi-flask-quart-2022/.


There are new logos for all the Pallets projects and Pallets itself, based on a common theme.


https://pgjones.dev

I blog mostly about Python web developed, especially Flask, Quart and Hypercorn related aspects.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: