0

I am having a problem while trying to import imdb data from text files to MySQL database using imdbpy2sql.py script.

It throws the following error. It seems like the exception handler code tries to insert a duplicated record into cast_info table with existing primary key.

Can anyone help me fix this problem or suggest any work around solution?

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'")
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
K Hein
  • 894
  • 2
  • 12
  • 23
  • 1
    If you are using Mysql as your backend, please make sure you use --mysql-force-myisam and set your mysql engine to myisam, I wasted a lot of time trying out under innodb (really really slow mind you) – viper Mar 25 '13 at 06:28

1 Answers1

4

A lot of similar problems were fixed in the development version. Please try again with the version in the Mercurial repository: https://bitbucket.org/alberanid/imdbpy/

Davide Alberani
  • 1,061
  • 1
  • 18
  • 28