that's a hostname connection so it requires that you also include the driver name in the URL. follow the example at https://docs.sqlalchemy.org/en/14/dialects/mssql.html#hostname-connections .
more background on connecting with pyodbc at https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Linux . if you can get pyodbc to connect directly we can show you the correct URL format. On Mon, Nov 9, 2020, at 11:22 PM, Larry Martell wrote: > sqlacodegen mssql+pyodbc://user:password@host/database > > On Monday, November 9, 2020 at 11:03:03 PM UTC-5 Mike Bayer wrote: >> __ >> this has to do with how you are formatting your URL, and it is being seen as >> a hostname and not a DSN name. can't provide any more help without seeing >> how you are formatting this URL as well as what is the actual method you are >> trying to use to connect (DSN or hostname). >> >> >> >> >> On Mon, Nov 9, 2020, at 6:44 PM, Larry Martell wrote: >>> I am trying to use sqlacodegen on a mac to generate models from a MS SQL >>> db. I get this error when I run: >>> >>> sqlacodegen mssql+pyodbc:xxx >>> pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data >>> source name not found and no default driver specified (0) >>> (SQLDriverConnect)') >>> I can successfully connect to the db using the same DSN: >>> $ python3.8Python 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39) >>> [Clang 6.0 (clang-600.0.57)] on darwin >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> from sqlalchemy import create_engine >>> >>> create_engine("mssql+pyodbc://xxx") >>> /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sqlalchemy/connectors/pyodbc.py:80: >>> SAWarning: No driver name specified; this is expected by PyODBC when using >>> DSN-less connections >>> util.warn( >>> Engine(mssql+pyodbc://xxx) >>> >>> >>> >>> >>> -- >>> 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+...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sqlalchemy/45a0c405-f6c9-4778-8e5c-fd179f633f45n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/sqlalchemy/45a0c405-f6c9-4778-8e5c-fd179f633f45n%40googlegroups.com?utm_medium=email&utm_source=footer>. >> > > -- > 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/80a46434-b025-4cbe-89a7-886f8c8869fcn%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/80a46434-b025-4cbe-89a7-886f8c8869fcn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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/ca34bb52-1a01-4f38-90c4-6df0ad4fa9dd%40www.fastmail.com.