2012-02-04 3 views
0

나는 기본적으로 새 데이터베이스를 만들고 다음에 따라 데이터베이스 값을 입력하는 것을 시도하고있다 : "sqlite3.OperationalError 그것을 실행하는 동안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() 

을하지만를 : 그러한 테이블이 없습니다 : main.wordlist Error "가 발생했습니다. 왜 검색 데이터베이스를 찾을 수 없는지 잘 모르겠습니다. 적어도 라이브 컴파일러에서 실행해야합니다. 왜 제대로 작동하지 않는지 나는 모른다. 누구든지 도와 줄 수 있습니까?

답변

0

오타가 있습니다 두 번째 줄에 변경 그렇다면 :? wordlist 있어야 worldlist됩니다

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

처음에는 생각했지만 개선하기 위해 모든 방법을 시도했지만 실제로 해결되지 않았습니다. 나는 현재 옵션이 없다. –

관련 문제