IMDB 到 MySQL:将 IMDB 数据插入 MySQL 数据库

发布于 2024-12-01 21:06:25 字数 322 浏览 4 评论 0原文

我正在寻找一种解决方案,将所有 IMDB 数据导入我自己的 MySQL 数据库。我已经从他们的主页下载了所有 IMDB 数据文件,这些文件都是 *.list 文件格式(在 Windows 中)。

我想检索该信息并将其正确插入到我的 MySQL 数据库中,以便我可以进行一些测试和查询搜索。

我遵循了一份指南,但大约有一半的人意识到这是 2004 年的指南,现在的工作方式与七年前的工具不太协调。

我浏览了网络的应用程序、php 脚本、python 脚本等,但没有找到解决方案。 IMDB 本身引用的 W32 工具也不起作用。

有谁知道解决方案或完成这项任务的方法吗?

I’m looking for a solution to import all the IMDB data into my own MySQL database. I’ve downloaded all the IMDB data files from their homepage which are all in the file format *.list (in Windows).

I want to retrieve and that information and insert it correctly into my MySQL database so I can do some test and query searches.

I followed a guide but about half I realized that it was a 2004 guide and the way things works now did not go well with the tools from seven years ago.

I’ve browsed the net for applications, php-scripts, python-script and what not to find a solution but with no luck. The W32 tool that IMDB themselves references to don’t work either.

Is there anyone who knows a solution or a way to do this task?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

短暂陪伴 2024-12-08 21:06:25

有一些不错的py脚本,女巫帮助了我。只需建立连接并运行即可。 〜1小时解决所有问题。

编辑:使用此自述文件来制作脚本。

There is some nice py script, witch helped me. Just make connection and run it. ~1hr to work around everything.

EDIT: Use this readme file for making script.

哑剧 2024-12-08 21:06:25

IMDbPY 和 IMDb 数据文件格式的更改意味着现有答案不再有效(截至 2018 年 1 月)。

我使用的是 Ubuntu 17.10 和 MariaDB 10.1(不是 MySQL,但以下也适用于 MySQL)。

IMDbPY 的变化

IMDbPY 的最新版本是 6.2,它是在 Python 3 中实现的,并且依赖于 gccSQLObject< /code> 已被删除。另外,Python 包 MySQL-python 不适用于 Python 3,因此我们安装 mysqlclient;见下文。 (mysqlclient 的 API 与 MySQL-python 兼容。)

对 IMDb 数据文件格式的更改

更改为IMDb 数据文件格式于 2017 年 12 月推出,IMDbPY 6.2(当前版本)尚不支持新文件格式。 (请参阅 GitHub 问题。)

在解决此问题之前,请使用最新版本的以旧格式发布的 IMDd 数据,可在 ftp://ftp.fu-berlin.de/pub/misc/movies/database/frozendata/。下载所有 *.list.gz 文件(不包括子目录中的文件)。

要遵循的新步骤

  1. 安装 Python 3 和所需的软件包:

    sudo apt install python3
    pip3安装mysql客户端
    
  2. 在MariaDB中,创建数据库imdb,并授予user所有权限
    使用密码密码

    创建数据库 imdb;
    将 imdb.* 上的所有权限授予由“密码”标识的“用户”@“本地主机”;
    同花顺特权;
    
  3. 获取 IMDbPY 6.2:

    wget https://github.com/alberanid/imdbpy/archive/6.2.zip
    解压6.2.zip
    cd imdbpy-6.2
    python3 setup.py 安装
    
  4. 将 IMDb 数据加载到 MariaDB:

    <前><代码>cd bin
    python3 imdbpy2sql.py -d [imdb_dataset_directory] ​​-u 'mysql://用户:密码@localhost/imdb'

编辑: IMDbPY 6.2 版本不会创建外键。请参阅 GitHub 问题。如果需要创建外键,则需要使用旧版本的 IMDbPY,但也报告了旧版本中生成外键的问题(请参阅链接的 GitHub 问题)。

更新:导入花了 4.5 小时,而且我使用 InnoDB 表没有任何问题。

编辑:如果希望使用 IMDbPY 6.2 版本并需要外键,那么您需要在生成数据库后手动将它们添加到数据库中。在添加外键之前,需要对数据进行少量清理。 此 GitHub 问题。

Changes to IMDbPY and the IMDb data files format mean that the existing answers no longer work (as of January 2018).

I am using Ubuntu 17.10 and MariaDB 10.1 (not MySQL, but the following will also work with MySQL).

Changes to IMDbPY

The latest version of IMDbPY is 6.2, it is implemented in Python 3, and the dependencies on gcc and SQLObject have been removed. Also, the Python package MySQL-python is not available for Python 3, so we install mysqlclient instead; see below. (The API of mysqlclient is compatible with MySQL-python.)

Changes to the IMDb data files format

Changes to the format of the IMDb data files were introduced in December 2017, and IMDbPY 6.2 (the current version) does not yet work with the new file format. (See this GitHub issue.)

Until this is fixed, use the most recent version of the IMDd data published in the old format, which is available at ftp://ftp.fu-berlin.de/pub/misc/movies/database/frozendata/. Download all *.list.gz files (excluding files from subdirectories).

New steps to follow

  1. Install Python 3 and required packages:

    sudo apt install python3
    pip3 install mysqlclient
    
  2. In MariaDB, create a database imdb, and grant all privileges to user
    with password password.

    CREATE DATABASE imdb;
    GRANT ALL PRIVILEGES ON imdb.* TO 'user'@'localhost' IDENTIFIED BY 'password';
    FLUSH PRIVILEGES;
    
  3. Get IMDbPY 6.2:

    wget https://github.com/alberanid/imdbpy/archive/6.2.zip
    unzip 6.2.zip
    cd imdbpy-6.2
    python3 setup.py install
    
  4. Load IMDb data into MariaDB:

    cd bin
    python3 imdbpy2sql.py -d [imdb_dataset_directory] -u 'mysql://user:password@localhost/imdb'
    

Edit: Version 6.2 of IMDbPY does not create foreign keys. See this GitHub issue. You will need to use an older version of IMDbPY if you need foreign keys to be created, but there are also reported issues with the generation of foreign keys in old versions too (see linked GitHub issue).

Update: It took 4.5 hours to import, and I had no problems using InnoDB tables.

Edit: If wish to use version 6.2 of IMDbPY and require foreign keys, then you will need to add them manually to the database after it is generated. A very small amount of cleanup of the data is required before foreign keys can be added. This cleanup and the foreign keys that need to be added are described in this GitHub issue.

﹎☆浅夏丿初晴 2024-12-08 21:06:25

在 ubuntu 上

1) 安装所有必需的软件包。

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。

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)在mysql中,创建数据库“imdb”,并授予“user”所有权限,密码“password”。

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)加载IMDB数据到mysql(使用myisam作为存储引擎)。

cd [IMDBPY_parent_directory]/IMDbPY-5.1/bin
python imdbpy2sql.py -d [imdb_data_directory] -u
'mysql://user:password@localhost/imdb' --mysql-force-myisam

借用“导入 IMDb 数据集从纯文本文件到 MySQL 数据库”,并进行了一些小修复。

On ubuntu

1) Install all the required packages.

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) Install IMDBPY.

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) In mysql, create a database "imdb", and grant all privileges to "user" with password "password".

CREATE DATABASE imdb;
GRANT ALL PRIVILEGES ON imdb.* TO 'user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

4) Download all IMDB data.

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) Load IMDB data to mysql (use myisam as the storage engine).

cd [IMDBPY_parent_directory]/IMDbPY-5.1/bin
python imdbpy2sql.py -d [imdb_data_directory] -u
'mysql://user:password@localhost/imdb' --mysql-force-myisam

Borrowed from "Import IMDb Data Set from Plain Text Files To MySQL Database" with some minor fixes.

雨落□心尘 2024-12-08 21:06:25

IMDB 客户端进行了更新,并添加了一些文档,使得其中一些内容已经过时。请参阅更新的文档了解最新信息。

There has been an update to the imdb client and some documentation added making some of this outdated. Refer to updated docs for the latest.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文