Error Connecting to MSSQL using pyodbc and SqlAlchemy 0.5.0

202 views
Skip to first unread message

TJ Ninneman

unread,
Jan 9, 2009, 4:58:19 PM1/9/09
to sqlalchemy
Since I've been having troubles with pymssql and 0.5.0 I thought I
would try pyodbc on my Mac.

I'm able to connect and execute sql using isql without issue:

isql -v MyDbODBC username password

But when I connect through SqlAlchemy using:

sqlalchemy.url = mssql://username:password@/?dsn=MyDbODBC

I get:

DBAPIError: (Error) ('00000', '[00000] [iODBC][Driver
Manager]dlopen(FreeTDS, 6): image not found (0) (SQLDriverConnectW)')
None None

Any Ideas? What exactly does "Image not found" mean?

Thanks!

TJ

TJ Ninneman

unread,
Jan 9, 2009, 5:18:09 PM1/9/09
to sqlal...@googlegroups.com

I run this in the context of Pylons...a sqlalchemy only example:

>>> import sqlalchemy
>>> engine = sqlalchemy.create_engine('mssql://username:password@/?
dsn=MyDbODBC')
>>> con = engine.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line
1231, in connect
return Connection(self, **kwargs)
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line
538, in __init__
self.__connection = connection or engine.raw_connection()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line
1286, in raw_connection
return self.pool.unique_connection()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 142, in
unique_connection
return _ConnectionFairy(self).checkout()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 323, in
__init__
rec = self._connection_record = pool.get()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 180, in
get
return self.do_get()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 615, in
do_get
con = self.create_connection()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 145, in
create_connection
return _ConnectionRecord(self)
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 217, in
__init__
self.connection = self.__connect()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/pool.py", line 280, in
__connect
connection = self.__pool._creator()
File "/Users/tninneman/Development/twopeas/lib/python2.5/site-
packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/strategies.py",
line 80, in connect
raise exceptions.DBAPIError.instance(None, None, e)
sqlalchemy.exceptions.DBAPIError: (Error) ('00000', '[00000] [iODBC]

[Driver Manager]dlopen(FreeTDS, 6): image not found (0)
(SQLDriverConnectW)') None None
>>>

TJ

Lukasz Szybalski

unread,
Jan 9, 2009, 5:27:54 PM1/9/09
to sqlal...@googlegroups.com


What is mac using to connect to mssql? For example on unix there is a
freetds (free version of ms driver for sql server) and unixodbc. If
mac is using the same thing then you can try:

http://lucasmanual.com/mywiki/PythonManual#head-0e30402e75b2d4a8a032e6830813b779a34636e3

aka.
install unixodbc, crate driver name and connect using the connection
string mentioned there.

Lucas

Rick Morrison

unread,
Jan 9, 2009, 5:46:39 PM1/9/09
to sqlal...@googlegroups.com
The MSSQL connection string changed for the 0.5 final release. In particular, the "dsn" keyword is removed, and the pyodbc connection string now expects the DSN to be named where the "host" was previously placed, so the new connection URL would be:

   mssql://username:password@MyDbODBC

For fine-grained control over pyodbc connections, a new "odbc_connect" keyword allows a full ODBC connection string to be specified.

See the mssql module doc comments for details.

Rick

Lukasz Szybalski

unread,
Jan 10, 2009, 12:10:30 AM1/10/09
to sqlal...@googlegroups.com


ok.

I'll test it out on monday..
http://www.sqlalchemy.org/docs/05/reference/dialects/mssql.html#connecting


ps. I miss the "one page" documentation(easier to search) , is that
available or can be done with sphinx?

Thanks,
Lucas

Michael Trier

unread,
Jan 10, 2009, 12:21:08 AM1/10/09
to sqlal...@googlegroups.com
Hi,

On Sat, Jan 10, 2009 at 12:10 AM, Lukasz Szybalski <szyb...@gmail.com> wrote:

On Fri, Jan 9, 2009 at 4:46 PM, Rick Morrison <rickmo...@gmail.com> wrote:
> The MSSQL connection string changed for the 0.5 final release. In
> particular, the "dsn" keyword is removed, and the pyodbc connection string
> now expects the DSN to be named where the "host" was previously placed, so
> the new connection URL would be:
>
>    mssql://username:password@MyDbODBC
>
We actually left support for that in there just so we wouldn't break everyone's connection strings, but you should use the new syntax.
 
ps. I miss the "one page" documentation(easier to search) , is that
available or can be done with sphinx?

Have you tried the sphinx search? I think it's the best thing ever.  Very handy and fast.

Michael Bayer

unread,
Jan 10, 2009, 12:03:26 PM1/10/09
to sqlal...@googlegroups.com


download the PDF, that's what it's for. I dont update it quite as
frequently as the HTML docs tho.

Reply all
Reply to author
Forward
0 new messages