2012-02-04 74 views
0

我基本上是試圖創建一個新的數據庫,然後輸入按照以下數據庫值:sqlite3.OperationalError:沒有這樣的表:main.wordlist錯誤

def createindextables(self): 
    self.con.execute('create table urllist(url)') 
    self.con.execute('create table worldlist(word)') 
    self.con.execute('create table wordlocation(urlid,wordid,location)') 
    self.con.execute('create table link(fromid integer,toid integer)') 
    self.con.execute('create table linkwords(wordid,linkid)') 
    self.con.execute('create index wordidx on wordlist(word)') 
    self.con.execute('create index urlidx on urllist(url)') 
    self.con.execute('create index wordurlidx on wordlocation(wordid)') 
    self.con.execute('create index urltoidx on link(toid)') 
    self.con.execute('create index urlfromidx on link(fromid)') 
    self.dbcommit() 

但在運行它「sqlite3.OperationalError:沒有這樣的表:main.wordlist錯誤「即將到來。我不知道爲什麼它無法檢測到搜索數據庫。它至少應該從現場編譯器運行。我不知道爲什麼它不能正常工作。誰能幫忙?

回答

0

它可能由一個錯字:是worldlist應該是wordlist: 如果是這樣,改變第二行:

self.con.execute('create table wordlist(word)') 

(否則,行

self.con.execute('create index wordidx on wordlist(word)') 

可能提高wordlist尚未定義的錯誤


正如一個全面的檢查,你可以嘗試運行

import sqlite3 
connection = sqlite3.connect(':memory:') 
cursor = connection.cursor() 
cursor.execute('create table urllist(url)') 
cursor.execute('create table wordlist(word)') 

此代碼應工作。然後,您可以嘗試比較此代碼與您的不同之處。

+0

這就是我最初的想法,但我試圖改進它的所有方法,它並沒有真正解決。目前我沒有選擇 – 2012-02-04 20:15:31

相關問題