Skip to content

Add Python CSV export helper - #869

Open
RamiNoodle733 wants to merge 4 commits into
simonw:mainfrom
RamiNoodle733:issue-580-python-csv-export
Open

Add Python CSV export helper#869
RamiNoodle733 wants to merge 4 commits into
simonw:mainfrom
RamiNoodle733:issue-580-python-csv-export

Conversation

@RamiNoodle733

@RamiNoodle733 RamiNoodle733 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #580.

Adds sqlite_utils.export.rows_to_csv_file() for streaming the rows from a DB-API cursor to a CSV-compatible text stream from Python code.

The helper:

  • writes column names from cursor.description by default
  • supports headerless output
  • supports TSV or custom CSV dialects through dialect=
  • forwards CSV writer options such as lineterminator=
  • streams the cursor rather than materializing all rows

Targeted tests cover CSV output, quoted values, headerless output, TSV output, and the error case where a cursor has no result columns.

Validation performed: a focused Python verification of the exact helper behavior and expected outputs passed. The full repository suite was not run because the execution environment could not resolve github.com for a checkout.


📚 Documentation preview 📚: https://sqlite-utils--869.org.readthedocs.build/en/869/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add way to export to a csv file using the Python library

1 participant