I have a question about Django, unixODBC, FreeTDS, Apache2, mod_wsgi, which is somewhat similar to this question asked earlier on SO.
I have a Django site created to run on the latest Django, i.e. 1.2.3. It uses mostly managed models, including, with the exception of session information, nothing is written to the Django database, only read from it.
The entered database is hosted on a Windows machine on MSSQL 2005.
The Django project is hosted on a Linux machine. It is served through mod_wsgi on Apache2. Database connection occurs through the infamous FreeTDS and unixODBC duels. The latest versions of both FreeTDS and unixODBC have been launched. At the end of Python, pyodbc and django-pyodbc are used for the database material.
The project is deployed on two Linux servers with identical settings, which are located behind the load balancer. One database server is connected to it.
There are some intermittent issues on live production servers. On pages that request the DB to sometimes display entries, and sometimes I mean, an exception is thrown with an error:
('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLColAttribute)')
One of the strange bits about this riddle is that whenever you get this error, a simple update update in a web browser clears it and displays a page with records extracted from the database.
Generated SQL from debug output when an error occurs is very simple:
SELECT COUNT(*) FROM [TABLE] WHERE ([TABLE].[category] = 5 AND [TABLE].[newRelease] = 1 )
Django , , . , mod_wsgi , . mod_python, . mod_wsgi , , , . , , mod_wsgi , .
. , , . , . , , .
, - . , . .pyc, Apache .. , .
, .
.
. "never_cache" , , , , , Django . . .
# 2. sql_sever/pyodbc/base.py (django-pyodbc) , . SQL-, , -, :
sql = SELECT * FROM (SELECT [TABLE].[id], [TABLE].[productID], [TABLE].[title], [TABLE].[price], [TABLE].[rrp], [TABLE].[saving], [TABLE].[hmvPoints], [TABLE].[availability], [TABLE].[shipping], [TABLE].[rating], [TABLE].[thumbnail], [TABLE].[details], [TABLE].[images], [TABLE].[certImage], [TABLE].[trackListing], [TABLE].[category], [TABLE].[subCategory], [TABLE].[genreId], [TABLE].[bestSeller], [TABLE].[preOrder], [TABLE].[newRelease], (ROW_NUMBER() OVER (ORDER BY [TABLE].[id] ASC)) AS [rn] FROM [TABLE] WHERE [TABLE].[productID] = ? ) AS X WHERE X.rn BETWEEN 1 AND 21
params = (799742,)
exception = ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLColAttribute)')
sql = SELECT * FROM (SELECT (1) AS [a], (ROW_NUMBER() OVER (ORDER BY RAND() )) AS [rn] FROM [django_session] WHERE [django_session].[session_key] = ? ) AS X WHERE X.rn BETWEEN 1 AND 1
params = ('e4b669b40d10c336d62c8435198bf1db',)
exception = ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLColAttribute)')