I am using the sqlite3 library of python to process a Wikipedia .sql data dump, and I get the following “syntax error” report:
sqlite3.OperationalError: no such table: categorylinks
Below are the steps I have taken to import the .sql into my database
import sqlite3
con = sqlite3.connect('wikicategories.db')
infile = open('enwiki-latest-categorylinks.sql')
str = infile.read()
cur = con.cursor()
cur.execute(str)
and the beginning of the .sql file looks like this:
CREATE TABLE `categorylinks` (
`cl_from` int(8) unsigned NOT NULL DEFAULT '0',
`cl_to` varbinary(255) NOT NULL DEFAULT '',
`cl_sortkey` varbinary(230) NOT NULL DEFAULT '',
`cl_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`cl_sortkey_prefix` varbinary(255) NOT NULL DEFAULT '',
`cl_collation` varbinary(32) NOT NULL DEFAULT '',
`cl_type` enum('page','subcat','file') NOT NULL DEFAULT 'page',
UNIQUE KEY `cl_from` (`cl_from`,`cl_to`),
KEY `cl_timestamp` (`cl_to`,`cl_timestamp`),
KEY `cl_collation` (`cl_collation`),
KEY `cl_sortkey` (`cl_to`,`cl_type`,`cl_sortkey`,`cl_from`)
) ENGINE=InnoDB DEFAULT CHARSET=binary;
I really didn’t see any problem with the int(8) unsigned NOT NULL DEFAULT part. And this file is released by wikipedia hence should be ready to use. I know that the Python sqlite3 has a slightly different implementation w.r.t MySQL. Does it have something to do with this?
This is not SQL as understood by SQLite. Loading it with
sqlite3produces an error.This has nothing to do with Python.
You have two options: