Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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"?



He'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....

[2] https://github.com/kennethreitz/records/blob/master/records....

[3] http://initd.org/psycopg/docs/usage.html#server-side-cursors


I don't get why the export functionality would be combined into a query helper. Aren't those two quite different functions?


Since he's not using server side cursors, I believe all rows are pulled into ram when the query executes.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: