IMDbPY导入MySQL问题

时间:2011-09-20 10:48:23

标签: mysql imdbpy

尝试使用imdbpy2sql.py脚本将imdb数据从文本文件导入MySQL数据库时遇到问题。

它会抛出以下错误。似乎异常处理程序代码尝试使用现有主键将重复记录插入到cast_info表中。

任何人都可以帮我解决这个问题或建议解决方案吗?

SCANNING actor: Hall, Stephan
SCANNING actor: Halsey, William F.
 * FLUSHING CharactersCache...
 * TOO MANY DATA (100000 items in CharactersCache), recursion: 1
   * SPLITTING (run 1 of 2), recursion: 1
 * FLUSHING CharactersCache...
Traceback (most recent call last):
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 2951, in <module>
    run()
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 2812, in run
    castLists(_charIDsList=characters_imdbIDs)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 1576, in castLists
    doCast(f, roleid, rolename)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 1535, in doCast
    cid = CACHE_CID.addUnique(role)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 957, in addUnique
    else: return self.add(key, miscData)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 950, in add
    self[key] = c
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 860, in __setitem__
    self.flush()
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 912, in flush
    self.flush(quiet=quiet, _recursionLevel=_recursionLevel)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 883, in flush
    self._toDB(quiet)
  File "D:\project\IMDB\IMDbPY-4.7\bin\imdbpy2sql.py", line 1186, in _toDB
    CURS.executemany(self.sqlstr, self.converter(l))
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 206, in executemany
    r = r + self.execute(query, a)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.IntegrityError: (1062, "Duplicate entry '745684' for key 'PRIMARY'")

1 个答案:

答案 0 :(得分:4)

在开发版本中修复了许多类似的问题。 请使用Mercurial存储库中的版本重试: https://bitbucket.org/alberanid/imdbpy/