Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing .sql file into SQLite

Tags:

sql

sqlite

I'm trying to import a large .sql file into an SQLite .db file, but I'm getting the following errors:

sqlite> .read ./smsCorpus_en_2012.04.30.sql 
Error: near line 23: near "COMMENT": syntax error
Error: near line 50: near "LOCK": syntax error
Error: near line 52: near "some1": syntax error
Error: near line 58: near "s": syntax error
Error: near line 60: near "s": syntax error
Error: near line 66: near "UNLOCK": syntax error

The file is located at http://wing.comp.nus.edu.sg:8080/SMSCorpus/data/corpus/smsCorpus_en_sql_2012.04.30.zip (direct file link) linked on this page http://wing.comp.nus.edu.sg:8080/SMSCorpus/history.jsp

EDIT: just a warning, the file is quite large...not sure if this is the issue?

like image 687
muttley91 Avatar asked Oct 16 '12 17:10

muttley91


1 Answers

That file is a MySQL dump. To make SQLite understand it, you have to:

  • delete COMMENTs on the table fields;
  • remove AUTO_INCREMENT from id (INTEGER PRIMARY KEY fields are autoincrementing in SQLite anyway);
  • remove ENGINE and DEFAULT CHARSET;
  • remove LOCK/UNLOCK commands;
  • make the INSERT commands have fewer records;
  • replace \' quoting with ''.
like image 151
CL. Avatar answered Oct 10 '22 15:10

CL.