import pyodbc
from sqlalchemy import create_engine
def creator():
config = {
'driver': 'ODBC Driver 13 for SQL Server',
'host': 'localhost',
'port': 1433,
'user': 'me',
'pw': 'mypw',
'dbname': 'mydb'
}
return pyodbc.connect(
"DRIVER={{{driver}}};SERVER={host},{port};DATABASE={dbname};UID={user};PWD={pw}".format(
driver=config['driver'],
host=config['host'],
port=config.get('port',1433),
dbname=config['dbname'],
user=config['user'],
pw=config['pw']
)
)
# works
odbc_conn = creator()
# fails
e = create_engine('mssql://', creator=creator)
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.---You received this message because you are subscribed to the Google Groups "sqlalchemy" group.To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/d3691dac-431b-4ed1-8670-59b8b959f81f%40googlegroups.com.