2

I use pypy, pypyodbc and SQLAlchemy. I have problem of odbc connections.

I use:

engine = create_engine('mssql+pyodbc://dbuser:dbpasswd@localhost/dbname', echo = False)
Session = sessionmaker(bind=engine)

style try to connect the database.

The error is:

C:\pypy\site-packages\sqlalchemy\connectors\pypyodbc.py:82: SAWarning: No driver
name specified; this is expected by PyODBC when using DSN-less connections
"No driver name specified; "

The reason of this error, I find the connect parameter

 DRIVER={SQL Server Native Client}

is not transmit to the engine, in other word, I want to know how to set DRIVER string for this connections style for SQLALchemy.

user504909
  • 9,119
  • 12
  • 60
  • 109
  • The format should be ok. In my case, `oracle`, I'm providing `oracle://dbuser:dbpasswd@127.0.0.1/orcl` (although the concepts are a bit different in oracle). I'd say your problem is with precisely the `drivername` see [connection url](http://docs.sqlalchemy.org/en/rel_0_5/reference/sqlalchemy/connections.html), it would be `mssql+pyodbc` in your case. Can't try it for MS ddbb myself, sorry. Hope it helps in any way. – lrnzcig May 05 '15 at 13:50

3 Answers3

1

I've run into the same issue with Sybase ASE and after looking at the pyodbc.py source code you can pass GET-like parameters in your url. As an example (working for me):

sybase+pyodbc://username:password@hostname:5000/dbname?driver=Adaptive Server Enterprise

It's also sort of documented here with the connection string syntax being dialect://user:password@host/dbname[?key=value..]

Hope that helps

Alex
  • 198
  • 1
  • 10
  • @https://stackoverflow.com/users/2382554/alex - Can you please guide me how to use jdbc driver for sybase server connectivity? – Poonam Aug 24 '17 at 05:04
0

You may have also be been suffering from updating your SqlAlchemy version. As of the latest release (v1.0) you need to explicitly define your driver in the connection string for Microsoft SQL Server.

See: Changed in version 1.0.0: Hostname-based PyODBC connections now require the SQL Server driver name specified explicitly. SQLAlchemy cannot choose an optimal default here as it varies based on platform and installed drivers.

http://docs.sqlalchemy.org/en/latest/dialects/mssql.html#hostname-connections

See: Connecting to database using SQLAlchemy

Community
  • 1
  • 1
AZhao
  • 13,617
  • 7
  • 31
  • 54
0

I had this error message and fixed it by adding this to the end of the connection string:

"?driver=SQL+Server+Native+Client+10.0"
Phil Hunt
  • 507
  • 1
  • 4
  • 15