How not to load all Flask-SQLAlchemy binary query results in memory?

Viewed 21

I'm using PostgreSQL and Flask-SQLAlchemy to query. I have a binary table which contains both binary data and large blob objects (or at least their references, of course).

I need to download several files from the table and store them into the files system, and when I query the DB the memory usage gets way too high. I am wondering if calling .all() on the query loads all the binaries in memory? How to prevent that and yield the binary objects one by one? I'm also not sure that this would fix the problem. I'm afraid that I would still have issues with large blob objects.

Suggestions? Thanks guys

0 Answers
Related