Massi
unread,Nov 27, 2012, 9:30:31 AM11/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlal...@googlegroups.com
Hi everyone, as the title says I'm trying to run sqlalchemy (pyodbc) with SQL Server 2008 on Windows Server 2008 R2 sp1 but I'm failing with the database connection. Here is a small script I'm using to test the connection:
from sqlalchemy import *
from sqlalchemy.engine import reflection
url = "mssql+pyodbc://user:pass...@my.server.address/server_test"
e = create_engine(url)
insp = reflection.Inspector.from_engine(e)
print insp.get_table_names()
If I the script I get the following error:
Traceback (most recent call last):
File "connection.py", line 6, in <module>
File "C:\Python27\lib\site-packages\sqlalchemy\engine\reflection.py", line 118
, in from_engine
return Inspector(bind)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\reflection.py", line 94,
in __init__
bind.connect().close()
File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 2316, in
connect
return self._connection_cls(self, **kwargs)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 872, in _
_init__
self.__connection = connection or engine.raw_connection()
File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 2402, in
raw_connection
return self.pool.unique_connection()
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 169, in unique_c
onnection
return _ConnectionFairy(self).checkout()
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 371, in __init__
rec = self._connection_record = pool._do_get()
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 697, in _do_get
con = self._create_connection()
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 174, in _create_
connection
return _ConnectionRecord(self)
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 256, in __init__
self.connection = self.__connect()
File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 316, in __connec
t
connection = self.__pool._creator()
File "C:\Python27\lib\site-packages\sqlalchemy\engine\strategies.py", line 80,
in connect
return dialect.connect(*cargs, **cparams)
File "C:\Python27\lib\site-packages\sqlalchemy\engine\default.py", line 280, i
n connect
return self.dbapi.connect(*cargs, **cparams)
sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC SQL Serve
r Driver][DBNETLIB]Invalid connection. (14) (SQLDriverConnect); [01000] [Microso
ft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Invalid Instance()). (14)')
None None
The connection tested with SQL Server Management Studio works fine, so it should not be an authentication problem.
Has anyone an idea of what I'm doing wrong?
Thanks in advance!