I have a pyodbc
connection object using the keyword functionality of pyodbc.connect()
(https://github.com/mkleehammer/pyodbc/wiki/Module#connect).
The keywords include a driver parameter:
conn = pyodbc.connect(driver="SQL Server", server="myserver")
I am using this connection to pass to the SQLAlchemy create_engine()
function through the creator
parameter (docs) as per the suggestion at this answer:
engine = create_engine("mssql+pyodbc://", creator=lambda: conn)
However, the creator
parameter now ignores the connection parameters specified in the URL
parameter:
Usage of this function causes connection parameters specified in the URL argument to be bypassed.
This means I'm getting this warning message when creating the engine:
SAWarning: No driver name specified; this is expected by PyODBC when using DSN-less connections "No driver name specified; "
However, running a sql query as a test returns correct data. How can I supply the driver information (I'm assuming its mssql+pyodbc
) to the create_engine function to remove this warning?