0
votes

I tried to use pymsql with sqlalchemy using this code :

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

and this exception is raised here is the full stack trace :

    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
    
2

2 Answers

0
votes

Drop the : from your connection string after your username. It should instead be mysql+pymsql://root@localhost/pydb

0
votes

my working URI for sqlalchemy 0.9.4 and python3.3 is:

sqlalchemy.url = mysql+pymysql://user:password@host:port/database?charset=utf8&use_unicode=0

I use pymysql instead of pymsql.