Help with Insert Table data to MySQL Database

  1. My goal: insert Data from Excel file after it is showing in table component.
  2. Issue: SQL return error
  3. Steps I've taken to troubleshoot: Used Deepseek and ChatGPT
  4. Additional info: Self-hosted 3.114.3 and low to non knowlage about JS
INSERT INTO tempData
(
    Id,
    Produsent,
    CreatedDate  
)
VALUES
{{ table3.data
   .filter(row => row.fldbeskrId && row.Produsent)
   .map(row => `(
    '${row.Id}',
    '${row.Produsent}',
    ${row.CreatedDate ? `'${row.CreatedDate}'` : moment().add(1, 'hour').toISOString() }
)`).join(",") }}

I get:
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 '''' at line 8

I hope somebody can help me?

In advance thank you.

Hey @Thore! Thanks for reaching out.

The specific example I've shared below isn't 100% analogous, but my general recommendation is to use the GUI mode for inserting data.

The logic that you've written can mostly be copied and pasted - just make sure that the map callback is returning an array of objects instead of comma-separated strings. Let me know if you have any questions!

1 Like