Converting MySQL to PDF

I have read through a variety of responses in this forum and I can't get this to work:

I have a MySQL file called "Letter03" that I am trying to output as .PDF.

I am using code as below:

function convertToMarkdown(Letter03) {
const headers = [Object.keys(Letter03[0])];
const breaks = [headers[0].map(() => "---")];
const rows = data.map((r) => Object.values(r));
const tableEntries = headers.concat(breaks).concat(rows);
return tableEntries.map((row) => "|" + row.join("|") + "|").join("\n");
}

This generates the error message below:
ConvertToPdf1 failed (0.315s):You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'function convertToMarkdown(Letter03) { const headers = [Object.keys(Letter03[0])' at line 1

The MySql File "Letter03" is shown in the attached screen capture.

Any suggestions would be appreciated.

Mike