You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commands tried: csvsql --db mysql+mysqlconnector://$dbUser:$dbPass@$dbString:$dbPort/$dbSchema --tables test --unique-constraint Id --create-if-not-exist --prefix REPLACE --insert test.csv
csvsql --db mysql+mysqlconnector://$dbUser:$dbPass@$dbString:$dbPort/$dbSchema --tables test --unique-constraint Id --create-if-not-exist --prefix IGNORE --insert test.csv
When using IGNORE prefix the command finishes without any error, but with REPLACE it throws an ProgrammingError:
ProgrammingError: (mysql.connector.errors.ProgrammingError) 1064 (42000): 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 'REPLACE INTO test (Name, Id, Width) VALUES ('Charles', '1', '1')' at line 1
[SQL: INSERT REPLACE INTO test (Name, Id, Width) VALUES (%(Name)s, %(Id)s, %(Width)s)]
As you can see on the bottom line, I have tried to highlight the error. It should have been only "REPLACE INTO"
MySQL Documentation states that the correct syntax for REPLACE INTO does not have INSERT in front. https://dev.mysql.com/doc/refman/8.0/en/replace.html
As the syntax for IGNORE actually is "INSERT IGNORE INTO", this prefix does not throw an error.
The text was updated successfully, but these errors were encountered:
jpmckinney
changed the title
csvsql mysql REPLACE INTO syntax error
MySQL uses REPLACE and not INSERT OR REPLACE (though it does use INSERT IGNORE)
Oct 17, 2023
jpmckinney
changed the title
MySQL uses REPLACE and not INSERT OR REPLACE (though it does use INSERT IGNORE)
MySQL needs REPLACE and not INSERT OR REPLACE (though it does use INSERT IGNORE)
Oct 17, 2023
When using csvsql to insert csv files to MySQL database, the REPLACE prefix generates incorrect SQL and fails with error.
Tested on Debian WSL.
Test file attached but can be anything.
test.txt
Commands tried:
csvsql --db mysql+mysqlconnector://$dbUser:$dbPass@$dbString:$dbPort/$dbSchema --tables test --unique-constraint Id --create-if-not-exist --prefix REPLACE --insert test.csv
csvsql --db mysql+mysqlconnector://$dbUser:$dbPass@$dbString:$dbPort/$dbSchema --tables test --unique-constraint Id --create-if-not-exist --prefix IGNORE --insert test.csv
When using IGNORE prefix the command finishes without any error, but with REPLACE it throws an ProgrammingError:
As you can see on the bottom line, I have tried to highlight the error. It should have been only "REPLACE INTO"
MySQL Documentation states that the correct syntax for REPLACE INTO does not have INSERT in front.
https://dev.mysql.com/doc/refman/8.0/en/replace.html
As the syntax for IGNORE actually is "INSERT IGNORE INTO", this prefix does not throw an error.
The text was updated successfully, but these errors were encountered: