the MySQL node has some problems right now, like it won’t insert fields with a field name that contains a dash “-”, I guess there are also problems with accent symbols like è.
You can try to wrap all field names with special characters like you wrapped the data field like this:
In my case, I’ve to change the format of the date to the format my MySQL DB uses, I do not know if that format changes with locality, maybe @Jon or someone else knows more about that?
The weird part here is, that the MySQL node just does not save the date into the table, for me, it throws an error when the date is not in the right format.
I’ve made a sample workflow on how I convert the date in my workflows: (I’ve used your date string)
If you just try and insert only the date field does that work? It could just be that there is some difference in the formatting, Can you share what what the schema is for the table you are using?
Hi Jon, thanks for helping me. Here is how I created my table:
CREATE TABLE eventos_giovanne_saraiva (
Data TIMESTAMP,
Email VARCHAR(255),
Dono VARCHAR(255),
Descrição VARCHAR(255),
Origem VARCHAR(255),
Meio VARCHAR(255),
Retribuição VARCHAR(255),
Ação VARCHAR(255),
Situação VARCHAR(255),
PĂşblico VARCHAR(255),
Nome_Funil VARCHAR(255),
Utm_source VARCHAR(255),
Utm_id VARCHAR(255),
Utm_term VARCHAR(255),
Utm_campaign VARCHAR(255),
Utm_medium VARCHAR(255),
Utm_content VARCHAR(255))
Hi, Felix! I´ve tried to use the node you indicated to correct Date & Time, and added a Set node to filter only Date to add to BD so I can isolate this problem particulary to be solved. The following workflow is executing properly, but the date is still not bein added to my mySQL DB:
Here is the output in the mySQL DB after running the workflow above:
Felix, I noticed that even after using this block to transform the Date format, the output is still text, while my DB is set up to receive a timestamp. Isn’t this perhaps the problem?
How can I convert text to Date (timestamp format) in the n8n to send it to my mySQL DB?
there is no “timestamp” or “datetime” format, as the data is transferred with an SQL command, which is a string.
That means you have to convert a date object to an string which is in the format MySQL expects.
Usually that format is YYYY-MM-DD HH:mm:SS or as date 2023-01-26 15:11:00
In your workflow Example, you create a new string called “data” from the “Data” string in the “Set1” node.
Then you write the correct date format with the “Date & Time” node to the string called “data”.
But the field in your database is called “Data”, so the “Insert into MySQL” node uses the falsely formatted string from the “Data” string.
tldr: change the output string in the “Date & Time” node to “Data”
I’ve just tried it again with your schema and my test workflow, when correctly formatting the date it gets inserted into the table.
The interesting part is, when the date is not correctly formatted, like in your last workflow I get an error:
I can’t replicate a case where it does not insert anything /:
I’ve also just saw that you are using an “old” version of n8n, maybe update that to the newest version.
nvm, there is no newer Version for n8n Desktop
EDIT:
your last workflow example does not forward any items which have fields, which match the fields of your table, because the “Set1” node is set to “Keep only Set”.
Uhul!! Thanks, Felix!! It worked, the problem was indeed the name of the variable Data.
I had used the set to isolate the date input even, just to correct this problem.
So now, the only thing that is missing in the workflow is to remove the special characters before putting it into the database, so it doesn’t input NULL.
I’ve just tested special characters in n8n with the MySQL node and that just does not work right now in n8n.
The n8n Team is already working on an overhaul for the MySQL node which should fix that in the near future.
In the meantime, just remove the special characters from the MySQL table and set the names without special characters in n8n with a set node.
How to fix the content of the data to display the right characters instead of question mark symbols , I’ve no idea.
EDIT: just tested this and you can disable “Read As String” in the “Convert To Spreadsheet” node, with that the special characters get parsed correctly, at least for me
You still need to change the names in the database to field names without special characters, as that’s another problem.