Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using Python and SQLAlchemy to query a database that I did not create.

I have run into a problem querying a table that contains the SQL_VARIANT data type. I get the error:

sqlalchemy.exc.DBAPIError: (Error) ('ODBC data type -150 is not supported. Cannot read column Value.', 'HY000')

I confirmed with the database creator that the "Value" column is of type SQL_VARIANT. Does anyone know a way to load this data type using Python? I am currently using mssql with pyodbc.

Thank you for any help you can offer!

Versions:

Python 2.7,
SQLAlchemy 0.7.8
share|improve this question
    
What is connection string you are giving to SQLAlchemy? SQLA supports SQL_VARIANT so it looks to be a problem with the driver you are using to connect to the db. –  davidism Jun 30 '13 at 18:08
    
Thanks for the response @davidism. My connections string is: 'mssql+pyodbc://user:password@IPAddress/database' –  Brett D Jul 1 '13 at 17:41
    
How is this working with MSSQL? PyODBC needs a driver like FreeTDS to talk to MSSQL. A connection string I have used looks like: mssql://user:pass@host:port/db?driver=FreeTDS&tds_version=7.2. –  davidism Jul 1 '13 at 19:27
    
I can't say that I fully understand how everything is working, but the connection string above has allowed me to connect to and query the database. According to the MSSQL page on the SQLAlchemy website (docs.sqlalchemy.org/en/rel_0_7/dialects/mssql.html), my connection string would result in a connection of the form: DRIVER={SQL Server};Server=IPAddress;Database=database;UID=user;PWD=password. There is also the option of specifying a different driver as you have done. –  Brett D Jul 2 '13 at 16:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.