Better HN
topnewbestaskshowjobs
Log inSign up

pgjones

173 karma · joined Apr 23, 2015 (11y ago) · 46 submissions

pgjones.dev

Quart, Flask, Werkzeug and Hypercorn maintainer, active in the Python async community.

Submissions

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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

comment 1y ago · link · parent

Sorry that is a typo, I meant,

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

comment 1y ago · link · parent

Thank you! My Google foo did not find this.

comment 1y ago · link · parent

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

comment 1y ago · link · parent

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

7.

Show HN: SQL-tString a t-string SQL builder in Python(github.com ↗)

85 points · by pgjones · 1y ago · 35 comments

comment 1y ago · link · parent

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.

comment 2y ago · link · parent

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.

comment 2y ago · link · parent

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

comment 3y ago · link · parent

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

comment 3y ago · link · parent

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

13.

Tell HN: Flask and Quart have now partially merged

20 points · by pgjones · 3y ago · 7 comments

comment 3y ago · link · parent

https://pgjones.dev

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

15.

Tips and techniques for modern Flask apps(pgjones.dev ↗)

2 points · by pgjones · 3y ago · discuss

comment 3y ago · link · parent

I've three things :),

1. Quart, https://quart.palletsprojects.com, an ASGI (async/await) re-implementation of the Python web MicroFramework Flask. It is now maintained alongside, by the same people, as Flask.

2. Hypercorn, https://hypercorn.readthedocs.io, an ASGI/WSGI server that supports HTTP/1, HTTP/2, and HTTP/3.

3. My book "A Blueprint for Production-Ready Web Applications", which uses both of the above and shows a beginner how to build a full stack app (React frontend) running on AWS. See https://pgjones.dev/tozo/ for details, code, and link to the example app.

comment 4y ago · link · parent

It is also easier to manage for Flask - it is very mature and we fixed most of the issues present in FastAPI many years ago.

comment 4y ago · link · parent

Flask supports async, see https://flask.palletsprojects.com/en/2.1.x/async-await/.

Also see Quart https://github.com/pgjones/quart (which is Flask re-implemented with async-await) and Quart-Schema, https://github.com/pgjones/quart-schema for swagger docs.

19.

Faster Routing for Flask and Quart(pgjones.dev ↗)

4 points · by pgjones · 4y ago · discuss

comment 4y ago · link · parent

Or Hypercorn https://gitlab.com/pgjones/hypercorn if you want HTTP/1, HTTP/2, and HTTP/3.

comment 5y ago · link · parent

You can already do this using Hypothesis with the Pydantic plugin, https://pydantic-docs.helpmanual.io/hypothesis_plugin/. Here is an example for Quart-Schema (similar setup to FastAPI) https://pgjones.dev/blog/automatic-api-testing-2021.

comment 5y ago · link · parent

Hypercorn a Python ASGI server supports HTTP/3 built on aioquic which is a Python library supports QUIC.

(I'm the author of Hypercorn).

comment 6y ago · link · parent

Hi Hacker News,

I’ve reached an age now where I need to start thinking about my retirement, in addition to buying a house, saving for a wedding, starting a family, affording to pay for childcare, amongst other things. Frustratingly, it is really hard to know if I’m saving enough, or even how much I should be aiming to save. The best tools to solve my problem model cash flows and are only available through expensive financial advisors. I’ve built Moneyed to solve my own, and many other people’s, problem.

Moneyed, at the core, takes into account personalised financial goals and models cash flows i.e. the growth of assets, savings rates, and spending. Difficulties arise in the details, especially taking into account tax rules, and building a plan that is fully optimised (i.e. one where you minimise the amount you save whilst still being tax efficient and meeting your goals).

Moneyed also utilises Open Banking to give a full financial overview (UK current accounts, credit cards, savings, investments, pensions), to understand current spending, and to make it easy to know if you’re on track.

The backend of the app is built in Quart, an async version of Flask (Python), and utilises React for the frontend. The site also uses Quart for the backend but uses Svelte for the frontend. I’m the author of Quart, so it is an obvious choice for me. As for the frontend, React works really well for the app given the complexity, but I find it too heavy for the site. Fortunately Svelte exists, which I think is perfect for the site.

To build an optimised financial plan, we’re implementing SciPy’s minimize function as it enables us to model both linear and non-linear constraints and is relatively quick to solve (provided the initial first guess is good). We’re planning on leveraging more data science techniques: building a recommender engine to help people decide where to save/invest and cohort analysis to give for social validation and insights.

As for our go-to-market, we’re targeting young professionals working in tech as part of their employer’s benefits and wellbeing strategy as this enables us to create a “trigger” to get people thinking about their financial future.

24.

Show HN: Moneyed – be your own financial adviser – built with Quart and React(moneyed.co.uk ↗)

6 points · by pgjones · 6y ago · 1 comment

25.

Things you should be doing with cookies (but probably aren't)(moneyed.co.uk ↗)

4 points · by pgjones · 6y ago · discuss

comment 6y ago · link · parent

Potentially soon for Flask, https://github.com/pallets/flask/pull/3412. Also see Quart, https://gitlab.com/pgjones/quart

comment 6y ago · link · parent

It is possible to compare HTTP/3 to HTTP/2 & HTTP/1 using Python, as Hypercorn (via aioquic for HTTP/3) supports all three.

When I compared late last year I found HTTP/3 to be noticeably slower, https://pgjones.dev/blog/early-look-at-http3-2019/ however my test was much less comprehensive than the one here.

comment 6y ago · link · parent

I took an early look at the performance (using Python) in November which may also be of interest. https://pgjones.dev/blog/early-look-at-http3-2019/

(That site is also served over HTTP/3 if you want to try it out).

29.

An early look at HTTP/3(pgjones.dev ↗)

2 points · by pgjones · 7y ago · discuss

30.

How to serve HTTP 1, 2, & 3 in Python(pgjones.dev ↗)

2 points · by pgjones · 7y ago · discuss

12