2013-06-04 171 views
3

我安裝了IMDbPY並通過IMDb文件和imdb2py腳本創建了數據庫。現在我無法在腳本中使用該數據庫。當我嘗試使用DATABSE,我得到以下錯誤:無法訪問SQL數據庫

>>> 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' 

回答

6

嘗試使用URI指定的完整路徑。像這樣的東西應該工作:

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

請注意三重斜槓。