Monday, April 28, 2014

Data source name not found and no default driver specified - SQLalchemy/Sybase

I was getting this error when trying to connect to a sybase database using Microsoft's odbc driver by using the connection string shown in the SqlAlchemy examples:
DBAPIError: (Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') None None

The following code worked to connect:
import pyodbc, sqlalchemy

def connect():
    return pyodbc.connect('DSN=<dsn name>;UID=<username>;PWD=<password>')

srcEngine = sqlalchemy.create_engine('sybase+pyodbc://', creator=connect, echo=True)

No comments:

Post a Comment