2014-02-18 69 views
0

我嘗試使用此代碼使用pymsql與SQLAlchemy的: 錯誤:沒有重複

 
    from sqlalchemy import create_engine 
    engine = create_engine("mysql+pymsql://root:@localhost/pydb") 
    conn = engine.connect() 

這種異常在這裏提出的是完整的堆棧跟蹤:

 
    Traceback (most recent call last): 
     File "D:\Parser\dal__init__.py", line 3, in 
     engine = create_engine("mysql+pymsql://root:@localhost/pydb") 
     File "C:\Python33\lib\site-packages\sqlalchemy-0.9.2-py3.3.egg\sqlalchemy\engine__init__.py", line 344, in create_engine 
     File "C:\Python33\lib\site-packages\sqlalchemy-0.9.2-py3.3.egg\sqlalchemy\engine\strategies.py", line 48, in create 
     File "C:\Python33\lib\site-packages\sqlalchemy-0.9.2-py3.3.egg\sqlalchemy\engine\url.py", line 163, in make_url 
     File "C:\Python33\lib\site-packages\sqlalchemy-0.9.2-py3.3.egg\sqlalchemy\engine\url.py", line 183, in _parse_rfc1738_args 
     File "C:\Python33\lib\re.py", line 214, in compile 
     return _compile(pattern, flags) 
     File "C:\Python33\lib\re.py", line 281, in _compile 
     p = sre_compile.compile(pattern, flags) 
     File "C:\Python33\lib\sre_compile.py", line 498, in compile 
     code = _code(p, flags) 
     File "C:\Python33\lib\sre_compile.py", line 483, in _code 
     _compile(code, p.data, flags) 
     File "C:\Python33\lib\sre_compile.py", line 75, in _compile 
     elif _simple(av) and op is not REPEAT: 
     File "C:\Python33\lib\sre_compile.py", line 362, in _simple 
     raise error("nothing to repeat") 
    sre_constants.error: nothing to repeat 

回答

0

在您的用戶名後,從連接字符串中刪除:。應該改爲mysql+pymsql://[email protected]/pydb

+0

我試着刪除它,但問題依然存在。 – naguib

+0

對不起,我沒有先測試。你正在使用Python 3.3和SQLAlchemy 9.2? – ACV

+0

是的。這可能與使用這些版本有關嗎? – naguib

0

我工作的URI SQLAlchemy的0.9.4和python3.3是:

sqlalchemy.url = mysql+pymysql://user:[email protected]:port/database?charset=utf8&use_unicode=0 

我用pymysql代替pymsql的。