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?

5
  • How exactly did you create the file? Commented Oct 13, 2016 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. Commented Oct 17, 2016 at 8:54
  • Which editor? Which encoding? Commented Oct 17, 2016 at 9:10
  • @CL. sublime3 and UTF-8 Commented Oct 17, 2016 at 10:47
  • I guess that editor stores a Byte-Order Mark at the beginning of the file. Commented Oct 17, 2016 at 10:51

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
I ended up creating a new n++ file and placing it in there. It worked - but I still have no idea why :) Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.