1

I've referenced the following link for my problem Execute SQLite script , but it doesn't seem to assist with my experience.

I am new to sqlite, and currently attempting to execute a create table script from the command line using the .read FILENAME function.. My code is the following:

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE MovieList (ID   VARCHAR(255) PRIMARY KEY,
 Title    VARCHAR(255),
 Studio   VARCHAR(255)            ,
 Released   VARCHAR(255)        ,
 Status   VARCHAR(30)             ,
 Sound    VARCHAR(30)             ,
 Versions   VARCHAR(10)         ,
 Price   VARCHAR(15)         ,
 Rating   VARCHAR(15)             ,
 Movie_Year   VARCHAR(5)      ,
 Genre  VARCHAR(30)         ,
 Aspect   VARCHAR(15)             ,
 UPC   VARCHAR(255)             ,
 Release_Date   VARCHAR(255)                ,
 Last_Updated   VARCHAR(255)                 
);
COMMIT;

The error I get is Error: incomplete SQL: ??P and I'm not too sure how to go about fixing this. The alternative was to create the table and export the .dump file - and it had the same logic as above. Is there something I may be missing?

Community
  • 1
  • 1
Rain
  • 55
  • 4
  • How exactly did you create the file? – CL. Oct 13 '16 at 15:36
  • @CL. I initially created the script and got the error. Thereafter I ran everything in the command prompt (which worked). Exported the file, and copied the structure into a new script, and got the same error. I just want to understand why though. – Rain Oct 17 '16 at 08:54
  • Which editor? Which encoding? – CL. Oct 17 '16 at 09:10
  • @CL. sublime3 and UTF-8 – Rain Oct 17 '16 at 10:47
  • I guess that editor stores a Byte-Order Mark at the beginning of the file. – CL. Oct 17 '16 at 10:51

1 Answers1

0

Your SQL is correct, I've stored your script into script.sql and run:

sqlite3.exe my.db

sqlite> .read script.sql
sqlite> .exit

Db with required structure properly created. SQLite version 3.14.2

Typically Error: incomplete SQL: shows you statement with error. ??P means something wrong at the beginning of your file. Open it in Notepad++, View -> Show Symbol -> Show All Characters and check what is wrong there.

Nikita
  • 6,270
  • 2
  • 24
  • 37
  • Thanks for this - I've checked that and there was nothing obvious. I did imagine that the beginning of the file would be an issue but found no solution. – Rain Oct 17 '16 at 08:55
  • I ended up creating a new n++ file and placing it in there. It worked - but I still have no idea why :) Thanks. – Rain Oct 17 '16 at 09:12