On 7/25/06, Ray <[EMAIL PROTECTED]> wrote: > > We're using Oracle and SQL Server at work--the lack of support for > those two is really a killer. > > What is involved in creating such a support for a DB--any doc/anything > to start? Maybe I can take a look at the SQL Server side.
The short answer is that you need to add a backend for SQL Server. ado_mssql is there and close to working, but other backends might be useful. You can look at the existing backends for examples of what's needed, but mostly, it's translation from python types to DB types and shimming from an existing DB library to DB-API (and the convenience methods django expects over it). This has a long history: http://groups.google.com/group/django-developers/search?group=django-developers&q=%22sql+server%22+OR+mssql&qt_g=1&searchnow=Search+this+group In a nutshell: lots of people want support for SQL Server, but there are a couple sticking points. The major one is that SQL Server doesn't support LIMIT/OFFSET, which django needs (or needs a simulation of) to support QuerySet slicing, which is used for pagination (among other things). The community is certainly not against adding DB support, but the core developers are *nixen and so can't help much on this. Any testing and maintenance will have to be contributed. Longer answer: The existing nearly-working ado_mssql backend (look in django.db.backends.ado_mssql) is also Windows-only since it relies on ADO. There are loads of tickets related to getting this working, some of which are nearly complete. Unfortunately, I've lost track of which is which. Getting a single, consolidated ticket and closing all the others would probably really help get people focused. ;-) http://code.djangoproject.com/search?q=%22sql+server%22&ticket=on http://code.djangoproject.com/search?q=%22ado_mssql%22&ticket=on There's a cross-platform SQL Server library called pymssql which uses FreeTDS--- getting support using that would probably be preferable. There are some misgivings about using pymssql. One is that it depends on a deprecated library, "MS SQL 2000 DB-Library for C". To me, that doesn't matter, since it'll still work with SQL Server 2000 and 2005, and since a new wrapper for FreeTDS will be available by 2009. ;-) But also, using ODBC might work, see http://groups.google.com/group/django-developers/browse_thread/thread/c2d33cb6a9987eb6/f4907833618b80c5?lnk=gst&q=%22sql+server%22+OR+mssql&rnum=2#f4907833618b80c5 mxODBC apparently can interface with a large variety of ODBC drivers, and there is a *nix ODBC driver for SQL Server here: http://www.datadirect.com/products/odbc/index.ssp But don't expect stellar performance from django->mxodbc->datadirect->sql server. And I personally would rather eat dirt than pay for a data access library. :) That sort of thing is great to have when you realize valuable data is on the verge of being lost forever, but you can save it by shelling out some cash for migration to a more accessible system. Deploying it by choice as the backend accessor, eh, not so much. Another (misgiving about pymssql) is that, AFAICS, pymssql pulls back the entire resultset upon query execution, rather than fetching cursor pages. I think this is to satisfy the DB-API's cursor.rowcount requirement, which SQL Server can't supply using a forward-only (i.e. fast) cursor. ado_mssql doesn't do that, but instead doesn't comply with DB-API because it always returns a rowcount of -1 until you've fetched the whole set locally, which is less than useful. It comes down to a limitation in SQL Server. The only way to comply with DB-API without pre-fetching the entire resultset (which I think is a horrible idea) is to pre-select the count. Which is also a horrible idea since on edge cases the count could differ from the actual result due to interim updates or dirty reads. DB API 2.0 : http://www.python.org/dev/peps/pep-0249/ Another person is apparently currently looking at adding support for SQL Server: http://groups.google.com/group/django-developers/browse_thread/thread/6fa803c0fdcb82f3/76cbb95ec2fd6dfd?lnk=gst&q=%22sql+server%22+OR+mssql&rnum=4#76cbb95ec2fd6dfd As noted in that thread, django.db.models.query is being refactored currently, so you'll want to discuss with Adrian if changes in there are needed (and I think they probably are, I don't know what's involved with Oracle, since I haven't looked into it as much. I want Oracle support as well, but SQL Server matters more to me. ;-) ...I wish I had time to put this issue to bed. I've become the curator of the issue history since my failed attempt to get this working over PyCon (March 2006, should the date become of historical interest). At least I now have a message I can point future inquiries at. :) Lastly, this discussion probably should live on django-developers. Cheers, -Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---