example:

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)




/usr/lib/python3.6/site-packages/sqlalchemy/connectors/pyodbc.py:79: 
SAWarning: No driver name specified; this is expected by PyODBC when using 
DSN-less connections
  "No driver name specified; "


This is on SqlAlchemy 1.3.17


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/d3691dac-431b-4ed1-8670-59b8b959f81f%40googlegroups.com.

Reply via email to