IMDBPY 5.1을 사용하여 mysql 데이터베이스에 imdb 데이터를로드하려고했습니다. 하지만 결국에는 다음과 같은 문제가 발생합니다. 전체 기본 키 + 외래 키 제약 조건이 스키마에 있어야합니다. 가능한 원인이 무엇이겠습니까?imdbpy를 사용하여 mysql에 imdb 데이터를로드 할 때 외부 키를 추가 함
1) 필요한 모든 패키지를 설치 다음과 같이 내가 사용
building database indexes (this may take a while)
# TIME createIndexes() : 38min, 6sec (wall) 0min, 0sec (user) 0min, 0sec (system)
adding foreign keys (this may take a while)
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_d`, CONSTRAINT `title_episode_of_id_exists` FOREIGN KEY (`episode_of_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `aka_title_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `cast_info_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `complete_cast_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `movie_keyword_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `movie_link_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `movie_info_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `movie_info_idx_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
ERROR caught exception creating a foreign key: Cannot add or update a child row: a foreign key constraint fails (`imdb`.`#sql-65bf_e`, CONSTRAINT `movie_companies_movie_id_exists` FOREIGN KEY (`movie_id`) REFERENCES `title` (`id`))
# TIME createForeignKeys() : 655min, 16sec (wall) 0min, 0sec (user) 0min, 0sec (system)
RESTORING imdbIDs values for movies... WARNING: unable to restore imdbIDs using the temporary table (falling back to dbm): missing "title_extract" table (ok if this is the first run)
WARNING: unable to restore imdbIDs (ok if this is the first run)
RESTORING imdbIDs values for people... WARNING: unable to restore imdbIDs using the temporary table (falling back to dbm): missing "name_extract" table (ok if this is the first run)
WARNING: unable to restore imdbIDs (ok if this is the first run)
RESTORING imdbIDs values for characters... WARNING: unable to restore imdbIDs using the temporary table (falling back to dbm): missing "char_name_extract" table (ok if this is the first run)
WARNING: unable to restore imdbIDs (ok if this is the first run)
RESTORING imdbIDs values for companies... WARNING: unable to restore imdbIDs using the temporary table (falling back to dbm): missing "company_name_extract" table (ok if this is the first run)
WARNING: unable to restore imdbIDs (ok if this is the first run)
명령입니다.
sudo apt-get install -y gcc python python-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev python-setuptools python-pip
easy_install -U SQLObject
pip install MySQL-python
2) IMDBPY를 설치하십시오. MySQL의에서
cd [IMDBPY_parent_directory]
wget http://prdownloads.sourceforge.net/imdbpy/IMDbPY-5.1.tar.gz
tar -xzf IMDbPY-5.1.tar.gz
cd IMDbPY-5.1
python setup.py install
3) 데이터베이스 'IMDB "를 작성하고, 모든 권한을 부여 비밀번호"비밀번호 "와"사용자 "로 설정합니다.
CREATE DATABASE imdb;
GRANT ALL PRIVILEGES ON imdb.* TO 'user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
4) 모든 IMDB 데이터를 다운로드하십시오.
mkdir [imdb_data_directory]
cd [imdb_data_directory]
wget -r --accept="*.gz" --no-directories --no-host-directories --level 1 ftp://ftp.fu-berlin.de/pub/misc/movies/database/
5) mysql에 IMDB 데이터를로드하십시오.
cd [IMDBPY_parent_directory]/IMDbPY-5.1/bin
python imdbpy2sql.py -d [imdb_data_directory] -u
'mysql://user:[email protected]/imdb'
내 설정은 다음과 같습니다
파이썬- : 2.7
- MySQL은 : 5.7
- 우분투 16.04
가 나는 또한 맥 OS 10.12에 노력 MySQL은 5.7 + 파이썬 2.7 같은 문제가있었습니다. SQLObject의 대신 SQLAlchemy의를 사용 다비드의 제안을
는 :
python imdbpy2sql.py -d [imdb_file_directory] -o sqlalchemy -u 'mysql://user:[email protected]/imdb?charset=utf8&local_infile=1'
나는 다음과 같은 오류가 발생했습니다 :
나는 다음과 같은 명령을 사용하여 SQLAlchemy의 시도.
Traceback (most recent call last):
File "imdbpy2sql.py", line 538, in <module>
conn = setConnection(URI, DB_TABLES)
File "/Library/Python/2.7/site-packages/IMDbPY-5.1-py2.7-macosx-10.12-intel.egg/imdb/parser/sql/alchemyadapter.py", line 489, in setConnection
engine = create_engine(uri, **params)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/strategies.py", line 160, in create
engineclass.__name__))
TypeError: Invalid argument(s) 'local_infile' sent to create_engine(), using configuration MySQLDialect_mysqldb/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
저는 버전 1.1.8의 sqlalchemy를 사용하고있었습니다. sqlalchemy 버전 0.5로 전환 할 때 동일한 오류가 발생했습니다. 그리고 sqlalchemy 0.4로 전환했을 때이 오류가 발생했습니다 :
Traceback (most recent call last):
File "imdbpy2sql.py", line 323, in <module>
from imdb.parser.sql.alchemyadapter import getDBTables, setConnection
File "/Library/Python/2.7/site-packages/IMDbPY-5.1-py2.7-macosx-10.12-intel.egg/imdb/parser/sql/alchemyadapter.py", line 54, in <module>
UNICODECOL: UnicodeText,
NameError: name 'UnicodeText' is not defined
'local_infile'을 잘못 지정 했습니까?