Every recurring report has the same awkward moment. The numbers live in a database, the deadline is today, and the person waiting for the report cannot open a terminal, let alone run a query. So the results travel as a screenshot of a terminal window: unreadable at a glance, impossible to sort, and useless the moment anyone asks a follow-up question about the figures.

A report reader needs the data itself. The SQL to CSV Formatter on Ovatly turns the table your database client already printed into a clean CSV you can attach to the report. This guide walks through the workflow: run the query where you always run it, convert the printout, and hand over a file the reader can actually work with.

Contents

  • Quick answer
  • Why a terminal screenshot fails a report
  • The formats the formatter recognises
  • How to format SQL output as CSV for a report, step by step
  • Worked example: a MySQL result attached to a report
  • Checks to run before you attach the file
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Run the query in your own database client and copy the printed result table exactly as it appears, borders and all. Open the SQL to CSV Formatter, paste the output, leave the format on Auto-detect or pick it yourself, click Convert, check the preview, and download query-result.csv. Attach that file to the report. The tool never runs SQL and has no database connection: it converts text you paste, nothing more.

Why a terminal screenshot fails a report

A screenshot freezes the data into a picture. The reader cannot sort it, filter it, add a column of their own, or paste a figure into their own spreadsheet without retyping it, and retyping is where transcription errors creep in. A wide result is often cut off at the edge of the terminal window, so part of the data never reaches the report at all.

Pasting the raw printout into a document is barely better. The border characters and padding spaces that make a table readable in a terminal become junk columns and stray spaces in a spreadsheet. A CSV is the format reports actually want: plain rows and columns that every spreadsheet, and most reporting tools, open without complaint.

The formats the formatter recognises

Database clients print results in a small set of recurring styles, and the formatter handles each of them:

  • MySQL ASCII tables, with +---+ border lines above and below the header and the data.
  • psql output, where a line of dashes separates the header from the rows.
  • Whitespace-aligned columns with a dashed separator line, the style several other clients produce.
  • Tab or semicolon delimited text, for output that was already delimited but still needs cleaning into proper CSV.
  • A fallback for anything else: runs of two or more spaces count as the column separator.

Auto-detect is the sensible default, because the border and separator lines make most printouts easy to identify. If the preview shows columns merged or split in the wrong places, pick the format yourself and convert again.

How to format SQL output as CSV for a report, step by step

  1. Run your query in your usual database client and let it print the full result.
  2. Copy the entire printed table, including the header row and the border or separator lines. Do not tidy anything away: those lines are how the formatter finds the columns.
  3. Open the SQL to CSV Formatter and paste the output in.
  4. Leave the format on Auto-detect, or pick the format that matches your client.
  5. Click Convert and read the preview: the header should show your column names, and every row should have the same number of fields as the header.
  6. Download query-result.csv and attach it to the report alongside your written summary.

Worked example: a MySQL result attached to a report

Suppose the monthly report needs the two newest signups, and your MySQL query prints this table:

+----+------+
| id | name |
+----+------+
| 1  | Ana  |
| 2  | Ben  |
+----+------+

Paste it in, leave the format on Auto-detect, and convert. The downloaded query-result.csv contains exactly this:

id,name
1,Ana
2,Ben

The borders are gone, the padding around Ana and Ben is trimmed, and the header becomes the first row, so the reader's spreadsheet shows id and name as column names. If the printout ended with a summary line, that line is dropped during conversion rather than arriving in the report as a stray third record.

Checks to run before you attach the file

Thirty seconds of checking saves the embarrassment of a corrected attachment later. Compare the row count in the CSV against the count your client reported, remembering that the summary line itself is removed on purpose. Scan for any row with more fields than the header: that almost always means a value contained a pipe character, which the parser reads as a column border and splits on. Finally, decide what your report does about missing values: NULL arrives as the literal word NULL, so if your readers expect empty cells, find and replace before sending.

Limitations and honest tradeoffs

The formatter can only work with the printout you give it. Output copied through a chat window or a narrow terminal may already have lost its alignment, and no converter can rebuild columns that were mangled before pasting. Cell padding is trimmed during conversion, so a value that genuinely starts or ends with spaces loses them; that is the price of removing presentation padding, and it matters only for data that stores meaningful spaces.

This is also not a database export feature. It cannot fetch data, schedule a report or connect to anything. You still run every query yourself, under your own credentials, exactly as you do now.

Common mistakes

  • Sending a screenshot instead of data. The reader gets a picture they cannot sort, filter or reuse.
  • Tidying the printout before pasting. Removing border or separator lines removes the column map the formatter relies on.
  • Attaching the first conversion unchecked. For borderless output, glance at the preview; if the columns sit wrongly, pick the format manually and convert again.
  • Forgetting the pipe gotcha. A notes field containing a | splits its row into extra columns.
  • Assuming NULL became an empty cell. It arrives as the literal text NULL; replace it if your report convention differs.

FAQs

Can I attach the converted file to a report as it is? Yes. The download is a standard CSV named query-result.csv, with the column names as the first row, so a reader can open it in any spreadsheet and sort, filter or chart it straight away.

Which kinds of terminal output can I paste? MySQL ASCII tables with +---+ borders, psql output with dashed separators, whitespace-aligned columns with a dashed separator line, and tab or semicolon delimited text. If none of those match, it falls back to treating two or more spaces as the column separator.

What happens to the row count line at the bottom of my output? Summary lines such as (3 rows) are removed deliberately. They are the client commenting on the result, not part of the data, and keeping one would add a broken extra row to the report file.

Why does a cell in the CSV contain the word NULL? NULL is copied as the printed literal text, so the cell holds the word NULL rather than an empty value. If the report convention is empty cells for missing data, find and replace NULL after downloading.

Is my query data uploaded anywhere? No. The tool has no database connection and never runs SQL. You paste text you already retrieved under your own credentials, convert it, and download the file.

Conclusion

A good report attachment is boring in the best way: rows and columns that open cleanly for anyone. Run the query in your own client, paste the printed table into the SQL to CSV Formatter, and attach the CSV instead of a screenshot. When a converted file still looks wrong, our companion guide on SQL to CSV mistakes: headers, nulls and quoted fields explains the usual causes. For more in this series, see the Data and JSON Tools guides.

References