3

我已经安装了 IMDbPY 并通过 IMDb 文件和 imdb2py 脚本创建了一个数据库。现在我无法在我的脚本中使用该数据库。当我尝试使用数据库时,出现以下错误:

>>> from imdb import IMDb  
>>> i = IMDb('sql', uri='sqlite:/home/user/random/mov.db', useORM='sqlalchemy,sqlobject')  
2013-06-04 11:20:25,977 WARNING [imdbpy.parser.sql.alchemy] /usr/lib/python2.7/dist-packages/imdb/parser/sql/alchemyadapter.py:38: Unable to import migrate.changeset: Foreign Keys will not be created.  
Traceback (most recent call last):
  File "<input>", line 1, in <module>  
  File "/usr/lib/python2.7/dist-packages/imdb/__init__.py", line 199, in IMDb
    return IMDbSqlAccessSystem(*arguments, **keywords)  
  File "/usr/lib/python2.7/dist-packages/imdb/parser/sql/__init__.py", line 595, in __init__
    self._connection = setConnection(uri, DB_TABLES)  
  File "/usr/lib/python2.7/dist-packages/imdb/parser/sql/alchemyadapter.py", line 484, in setConnection  
    engine = create_engine(uri, **params)  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/__init__.py", line 332, in create_engine  
    return strategy.create(*args, **kwargs)  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 48, in create  
    u = url.make_url(name_or_url)  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/url.py", line 154, in make_url  
    return _parse_rfc1738_args(name_or_url)  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/url.py", line 196, in _parse_rfc1738_args  
    "Could not parse rfc1738 URL from string '%s'" % name)  
  ArgumentError: Could not parse rfc1738 URL from string 'sqlite:/home/user/random/mov.db'  
4

1 回答 1

6

尝试使用指定完整路径的 URI。像这样的东西应该工作:

sqlite:///home/user/random/mov.db

注意三个斜杠。

于 2013-06-11T18:20:39.930 回答