Discussion:
Using Sqlalchmy with pyodbc driver to access a MS SQL Server
Andrea Cappelli
2012-11-09 07:35:33 UTC
Permalink
Hi,
I'm trying to access a MS Sql Server from a python script using SQL Alchemy.

If I use pymssql driver everything works well, except I receive a warning
about Decimal field converted to float, with some possible data loss; so I
tried to switch to pyodbc driver that shouldn't have this issue, but was
not able to configure it on my Ubuntu 12.04 box, I receive the following
error:

sqlalchemy.exc.DBAPIError: (Error) ('IM004', "[IM004] [unixODBC][Driver
Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0)
(SQLDriverConnect)") None None

In my virtualenv there is:
1) pyodbc==3.0.6
2) SQLAlchemy==0.7.9

and I have set up the conf file /etc/odbc.ini as follows
[handle]

Driver = /usr/lib/x86_64-linux-gnu/libodbc.so.1

Description = description

Server = $db_host

Port = 1433

TDS_Version = 8.0

I use the following uri when connecting: mssql+pyodbc://user:***@handle

I have the following packages installed:
unixodbc
unixodbc-dev
freetds-dev
tdsodbc
python-dev

Anyone has a similar setup or can point me towards a saolution for thsi
issue?

Best regards
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/mAVileXg-cIJ.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Andrea Cappelli
2012-11-09 08:12:24 UTC
Permalink
Hi,
I solved the problem putting

[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

in /etc/odbcinst.ini

and using the following uri
mssql+pyodbc://user:***@host:1433/dbname?driver=FreeTDS

Hope this helps

Andrea


Il giorno venerdì 9 novembre 2012 08:35:33 UTC+1, Andrea Cappelli ha
Post by Andrea Cappelli
Hi,
I'm trying to access a MS Sql Server from a python script using SQL Alchemy.
If I use pymssql driver everything works well, except I receive a warning
about Decimal field converted to float, with some possible data loss; so I
tried to switch to pyodbc driver that shouldn't have this issue, but was
not able to configure it on my Ubuntu 12.04 box, I receive the following
sqlalchemy.exc.DBAPIError: (Error) ('IM004', "[IM004] [unixODBC][Driver
Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0)
(SQLDriverConnect)") None None
1) pyodbc==3.0.6
2) SQLAlchemy==0.7.9
and I have set up the conf file /etc/odbc.ini as follows
[handle]
Driver = /usr/lib/x86_64-linux-gnu/libodbc.so.1
Description = description
Server = $db_host
Port = 1433
TDS_Version = 8.0
unixodbc
unixodbc-dev
freetds-dev
tdsodbc
python-dev
Anyone has a similar setup or can point me towards a saolution for thsi
issue?
Best regards
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/pV6DlDSQC5wJ.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Davide Zanotti
2016-01-10 22:22:34 UTC
Permalink
THANK YOU!!!
Post by Andrea Cappelli
Hi,
I solved the problem putting
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
in /etc/odbcinst.ini
and using the following uri
Hope this helps
Andrea
Il giorno venerdì 9 novembre 2012 08:35:33 UTC+1, Andrea Cappelli ha
Post by Andrea Cappelli
Hi,
I'm trying to access a MS Sql Server from a python script using SQL Alchemy.
If I use pymssql driver everything works well, except I receive a warning
about Decimal field converted to float, with some possible data loss; so I
tried to switch to pyodbc driver that shouldn't have this issue, but was
not able to configure it on my Ubuntu 12.04 box, I receive the following
sqlalchemy.exc.DBAPIError: (Error) ('IM004', "[IM004] [unixODBC][Driver
Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0)
(SQLDriverConnect)") None None
1) pyodbc==3.0.6
2) SQLAlchemy==0.7.9
and I have set up the conf file /etc/odbc.ini as follows
[handle]
Driver = /usr/lib/x86_64-linux-gnu/libodbc.so.1
Description = description
Server = $db_host
Port = 1433
TDS_Version = 8.0
unixodbc
unixodbc-dev
freetds-dev
tdsodbc
python-dev
Anyone has a similar setup or can point me towards a saolution for thsi
issue?
Best regards
--
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 post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
Loading...