无法访问SQL数据库

时间:2013-06-04 06:03:51

标签: imdbpy

我已经安装了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'  

1 个答案:

答案 0 :(得分:6)

尝试使用指定完整路径的URI。这样的事情应该有效:

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

注意三重斜线。