Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error when loading from file

Tags:

sqlite

I execute: sqlite3 -init mydata.sql mydb with the following as the only line in mydata.sql:

DROP TABLE IF EXISTS [Album];

I get the following error:

Error: near line 1: near "DROP": syntax error

I've whittled the input file to virtually nothing and I always get this syntax error message no matter what command I enter and always on line 1. It looks like it thinks there's some unusual character but I can's see what it could be. Any thoughts?

like image 631
Robert Lewkovich Avatar asked Dec 06 '11 19:12

Robert Lewkovich


People also ask

How do you fix syntax error?

How to Fix It: If a syntax error appears, check to make sure that the parentheses are matched up correctly. If one end is missing or lined up incorrectly, then type in the correction and check to make sure that the code can be compiled. Keeping the code as organized as possible also helps.

Why do I keep getting a syntax error?

Syntax errors can occur from time to time when mixing groups such as HTML and XML. Different reasons can also cause this error. Syntax Error, an error that can occur due to a slight carelessness of the software, occurs during coding. The error that usually occurs when writing the source code can confuse the site.

What triggers a syntax error?

Syntax errors are mistakes in the source code, such as spelling and punctuation errors, incorrect labels, and so on, which cause an error message to be generated by the compiler. These appear in a separate error window, with the error type and line number indicated so that it can be corrected in the edit window.

How do you fix syntax errors in Python?

You can clear up this invalid syntax in Python by switching out the semicolon for a colon. Here, once again, the error message is very helpful in telling you exactly what is wrong with the line.


1 Answers

If you use Notepad++ or other similar text editor, enable showing all symbol.

In Notepad++, view->show symbol->Show All characters

Also check Encoding of this file (Menu->Encoding). You might want to forcefully change encoding to ANSI/UTF-8 (Menu->Encoding->Convert to ANSI).

like image 104
harsh Avatar answered Oct 11 '22 06:10

harsh