3 ms·
Looks awesome. A couple questions: If you do a query that returns 100 records and use rows.next(), does it just get them from the cursor without pulling down t
by benatkin 11y ago
Looks awesome. A couple questions:
If you do a query that returns 100 records and use rows.next(), does it just get them from the cursor without pulling down the rest from the database? Do you need to dispose of the cursor or is it automatically cleaned up?
The export formats are just a an attribute, not a method call. It would need to use @property IIRC. Does this go against the guideline in Python that "explicit is better than implicit"?
- pbreit 11y agoI don't get why the export functionality would be combined into a query helper. Aren't those two quite different functions?
- coleifer 11y agoSince he's not using server side cursors, I believe all rows are pulled into ram when the query executes.
- pyre 11y agoHe's using cursors directly from the his database library[1] which is psycopg2[2] (and we can also see that the cursor_factory is how the dicts are generated). The psycopg2 docs say[3]: When a database query is executed, the Psycopg cursor usually fetches all the records returned by the backend, transferring them to the client process. If the query returned an huge amount of data, a proportionally large amount of memory will be allocated by the client. [1] https://github.com/kennethreitz/records/blob/master/records.py#L108 https://github.com/kennethreitz/records/blob/master/records.... [2] https://github.com/kennethreitz/records/blob/master/records.py#L82 https://github.com/kennethreitz/records/blob/master/records.... [3] http://initd.org/psycopg/docs/usage.html#server-side-cursors http://initd.org/psycopg/docs/usage.html#server-side-cursors