Importing .sql file into SQLite - sql

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?

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 ''.

That is a MySQL Dump and not SQLite.
There are slight variations on the syntax.

Related

Getting sintax error while import dump into postgresql in Linux

I installed Postgresql on the Redhat Linux server and try to import the dump into the database At that time I'll get a syntax error.
sudo -u postgres -i psql db_test < data.sql
psql -h localhost -U postgres -W -d postgres < data.sql
Iam used these two commands to import data. At that time I'll get syntax error like this.
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `comment_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `comment_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `comment_details` WRITE;
^
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `comment_details` VALUES (3,1140,'ANAKAPALLI MAN...
^
ERROR: syntax error at or near "UNLOCK"
LINE 1: UNLOCK TABLES;
^
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `directory_org_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `directory_org_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `directory_org_details` WRITE;
^
invalid command \'s
invalid command \'s
invalid command \'s
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `directory_org_details` VALUES (1,'Daniel\'s Cri...
Please Help regarding This issue. Thanks in Advance.

sqlite3.OperationalError: near "--": syntax error

Can't find where is this typo or something - everytime getting this error line 33, in <module>
c_a.execute('ATTACH DATABASE temp.db AS check')
sqlite3.OperationalError: near "check": syntax error
I'm trying to attach database temp.db to the prime.db due one query. This has help me to find duplicate records (checking login (one of the columns in both databases))
import sqlite3
db_a = sqlite3.connect('prime.db')
c_a = db_a.cursor()
db_b = sqlite3.connect('temp.db')
c_b = db_b.cursor()
c_a.execute('ATTACH DATABASE temp.db AS check')
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
Also tried another version:
attachDatabaseSQL = "ATTACH DATABASE temp.db AS check"
dbSpec = ("temp.db",)
c_a.execute(attachDatabaseSQL, dbSpec)
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
It found the error:
line 41, in <module>
c_a.execute(attachDatabaseSQL, dbSpec)
sqlite3.OperationalError: near "check": syntax error
Use Python 3.8.1 and SQLite3.
UPDATE:
Changed it to:
c_a.execute('ATTACH DATABASE temp.db AS dbcheck')
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
And the ERROR NOW IS:
c_a.execute('ATTACH DATABASE temp.db AS dbcheck')
sqlite3.OperationalError: no such column: temp.db
ATTACH DATABASE temp.db AS check;
check is a reserved word in SQLite, as in most (if not all) other databases. In the syntax, it comes into play to define check constraints when creating tables.
Consider using another name, that does not conflict with a language keyword. For example:
ATTACH DATABASE temp.db AS dbcheck;

Can not export hive dat to local "cannot recognize input near '<EOF>' '<EOF>' '<EOF>'"

My query is insert overwrite local directory '/home/localfile'
And what is get is:
Error: Error while compiling statement: FAILED: ParseException line 1:48 cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in statement (state=42000,code=40000)

Error loading yelp dataset to postgreSQL

I'm trying to import the Yelp data from their sql file into a postgreSQL 10 database on Windoes by running the code:
psql -U postgres yelp_db < yelp_sql
and getting the errors below. As you can see it is probably due to the ` character. Is there any way to easy fix that? The file is 7.3GB so I'd like to avoid having to read it line by line to change the ` character to '.
ERROR: syntax error at or near "PaxHeader"
LINE 1: PaxHeader/yelp_db.sql17 uid=998889796
^
ERROR: syntax error at or near "`"
LINE 1: CREATE DATABASE /*!32312 IF NOT EXISTS*/ `yelp_db` /*!40100 ...
^
ERROR: syntax error at or near "USE"
LINE 1: USE `yelp_db`;
^
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `attribute`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `attribute` (

GNUstep.csh file will not source

When I try the following in my GNUstep/Makefiles directory:
source GNUstep.csh
I receive the following output:
bash: GNUstep.csh: line 84: syntax error near unexpected token `"${GNUSTEP_USER_CONFIG_FILE}"'
bash: GNUstep.csh: line 84: ` switch ("${GNUSTEP_USER_CONFIG_FILE}")'
Obviously something is wrong, but I don't really know bash and from what I see nothing appears to be mislabled, unless there isn't supposed to be quotes around the variable or something.