MySQL Node Error - SQL Syntax even though it is successful

Hello there,

I have a very simple flow - I am getting a couple of rows of data and want to insert this into a database (mariadb). For the first part it is a simple “HTTP request” and the second I am using the MySQL node.
I failed to make the MySQL node working through all 7 items (it always injects all 7 into the first db), so I switched to “Execute Query” and entered an expression which eats the tablename and the to be added value from the previous node.
It currently fails with the following error message:
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO table1 (value) VALUES ('35137.56')' at line 1
If I check the table - the data has been entered. The query is running correct in another tool.

Query which is being used
as expression:

INSERT INTO `{{$node["HTTP Request"].json["name"]}}` (`value`) VALUES ('{{$node["HTTP Request"].json["value"]}}')
INSERT INTO `table1` (`value`) VALUES ('35137.56')

I cannot understand why it is telling me that there is an error - can you help me?

N8N - latest version, running on ARM / dockered environment.
Mariadb is at version 5.5.68-MariaDB

1 Like

Hey @Manuel,

What happens if you use…

INSERT INTO {{$node["HTTP Request"].json["name"]}} (value) VALUES ("{{$node["HTTP Request"].json["value"]}}")

I was doing some stuff with mySQL / MariaDB the other day and had a few issues with queries that would normally work. It may also be worth making sure none of your values are empty as that caught me out as well.

2 Likes

Hello @Jon,

that worked. I figured it will be somewhere around that area of special chars / formatting, but it was a lot quicker with your advise.
Given that your answer is working - there is probably a possibility to improve the query parser of the mysql node - at least for getting rid of backticks and such.

Thanks a bunch!

2 Likes

I agree, that there is the result of me scratching my head for about an hour trying to work out what was going on :slightly_smiling_face:

I do have a note to take a look at the node to see what is happening and to see what can be improved.

2 Likes

Hehe,

I welcome your initiative - I did the same :slight_smile:

2 Likes