Url parsing for mysql+pyodbc broken?

Issue #1509 resolved
Former user created an issue

When i try to make an pyodbc connect as described in documentation: engine = create_engine('mysql+pyodbc://'+user+:+'passwd'+'@'+dsn+'?encoding=utf8&charset=utf8') i get: sqlalchemy.exc.DBAPIError: (Error) ('IM012', 'IM012 unixODBCManagerDRIVER keyword syntax error (0) (SQLDriverConnectW)') None None when i add driver: engine = create_engine('mysql+pyodbc://'+user+':'+'passwd'+'@'+dsn+'?encoding=utf8&charset=utf8&drivermyodbc-5.1') i get: sqlalchemy.exc.DBAPIError: (Error) ('IM012', 'IM012 unixODBCManagerDRIVER keyword syntax error (0) (SQLDriverConnectW)') None None Note: the dsn is sufficient whe i use pyodbc directly. I got it working with following call: engine = create_engine('mysql+pyodbc://'+dsn,connect_args={'charset':'utf8','encoding':'utf8','dsn':dsn,'driver':'myodbc-5.1','user':user,'password':passwd})

Comments (5)

  1. Former user Account Deleted
    • changed status to open
    • removed status

    why dosen't this work for me: create_engine('mysql+pyodbc://'+ user + ':' + passwd +'@'+ dsn + '?encoding=utf8',connect_args={'charset':'utf8'}) but this works: create_engine('mysql+pyodbc://'+user+':'+passwd+'@'+dsn,connect_args={'charset':'utf8','encoding':'utf8'}) in the documentation i read that same ways of parameter supplyment should lead to the same result. i tried also to pass the charset via url but that led to bad keyword: sqlalchemy.exc.DBAPIError: (Error) ('IM012', 'IM012 unixODBCManagerDRIVER keyword syntax error (0) (SQLDriverConnectW)') None None. so it just might not be accepted.

    Furthermore i noticed, that the documentation suggests here : http://www.sqlalchemy.org/docs/06/reference/sqlalchemy/connections.html?highlight=encoding

    to set the encoding to 'utf-8' which lead to segmentation fault of the python interpreter on my machine

  2. Former user Account Deleted

    Soryy: in the documentation i read that same ways of parameter supplyment should lead to the same result. i tried also to pass the charset via url but that led to bad keyword: should mean: in the documentation i read that BOTH ways of parameter supplyment should lead to the same result. i tried also to pass the charset via url but that led to bad keyword:

  3. Mike Bayer repo owner

    you mean to put a slash at the end:

    create_engine('mysql+pyodbc://scott:tiger@dsn/?encoding=utf8')

    Per pyodbc documentation, passing it as connect_args() should fail. Per http://code.google.com/p/pyodbc/wiki/Module the only arguments you can pass in connect_args are 'autocommit', 'ansi', 'unicode_results'. the rest have to be embedded in the DSN which is what passing them as ?foo=bar does.

  4. Log in to comment