0

When I do this

connexion.query(the_sql_file);

I have this error

Unhandled rejection SequelizeDatabaseError: 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 '; -- phpMyAdmin SQL Dump

because apparently, I have a very long .sql file with comments inside. There are a lot of comments marked with "-- comment"

Question: How to query this, with "--" comments, without throwing exceptions?

tobi6
  • 8,033
  • 6
  • 26
  • 41
J. Doe
  • 39
  • 2
  • Did you try removing the comments and then executing the same query ? – Alon Adler Jul 19 '17 at 10:18
  • No i can't because the .sql file that i must use has 2000 lines of code – J. Doe Jul 19 '17 at 10:19
  • I think Alon meant to give it a go to see if that is in fact what causes the error. – Tamas Jul 19 '17 at 10:20
  • Remove the comments with Regex. Find them as shown here in [Regex to find sql comments](https://stackoverflow.com/questions/21017075/regex-to-find-sql-comments) and remove them. Then execute the query to see if it works. – Alon Adler Jul 19 '17 at 10:22
  • You say it's 2000 lines, but how many comments are there? – JeffUK Jul 19 '17 at 10:33

2 Answers2

0

Try export file with this mysqldump -u root -p databasebame > database.sql --compact

In this "--comments" parts is not included.

and you can refer the link How can I get rid of these comments in a MySQL dump?

LogicBlower
  • 1,250
  • 1
  • 8
  • 14
0

You can use pg-minify to remove all comments, and minify the SQL at the same time.

vitaly-t
  • 24,279
  • 15
  • 116
  • 138