Getting error when pipe sql into sqlite3 utility
I'm getting the following error on Windows when I pipe a SQL file into the sqlite3.exe prebuilt command line utility and the SQL file contains a UTF-8 BOM (as create by Notepad.exe in Windows).
> SQLITE3.EXE test.db < cleanup.sql Error: near line 1: near "": syntax error
I believe there was a similar error reported a while ago, but that was from loading the SQL file from inside the utility which is not an option for me.
Currently I place a comment in the beginning of the file to avoid it skipping the first SQL command.
Any thoughts on how to avoid this?
(2.1) By Larry Brasfield (larrybr) on 2021-04-24 12:29:34 edited from 2.0 in reply to 1 [link] [source]
''' type cleanup.sql | sqlite3.exe '''
Thanks, but this gives the exact same error.
If you just do "type file.sql" on Windows 10, the UTF-8 BOM remain visible in the output. Then sqlite3.exe will still complain about it.
This problem is sqlite3.exe not filtering the 2 UTF-8 BOM bytes in the beginning of the file.
Please rebuild using the latest SQLite source code from trunk and let us know if that clears your problem.
After a struggle to build it, I now have a nice sqlite3.exe (with a file-icon) which no longer complains about Syntax Errors.
Thanks for the effort.