|
List Info
Thread: Problem and fix with ado_mssql
|
|
| Problem and fix with ado_mssql |

|
2006-02-27 21:48:02 |
Hi,
I am new to Django and building a model to show an existing
MS SQL
Server database using ado_mssql and adodbapi on Windows.
I have a simple 'courses' model working and I can call
courses.get_list() and get the full list of courses. When I
try to do a
query such as courses.get_list(code__exact='HR5166') I get
a
DatabaseError. The error is the same one shown here:
http://code.
djangoproject.com/ticket/644
The problem is that the %s parameters are never getting
converted to ?
style - the patched Cursor and Connection code in
ado_mssql.py is never
executed.
The reason the patch code is never executed is because the
Connection
class is actually defined and accessed in adodbapi.adodbapi
(the
adodbapi module of the adodbapi package). The current patch
only
changes the package-level reference to Connection created in
adodbapi.__init__, it doesn't change the class actually
used in
adodbapi.connect()
The fix is to patch in both places - the public reference in
adodbapi
and the module-level reference in adodbapi.adodbapi. Here is
a diff,
with this fix I can query my database correctly:
Index: django/core/db/backends/ado_mssql.py
============================================================
=======
--- django/core/db/backends/ado_mssql.py (revision 2415)
+++ django/core/db/backends/ado_mssql.py (working copy)
 -27,7
+27,11 
class Connection(Database.Connection):
def cursor(self):
return Cursor(self)
+
+# Patch adodbapi to use our connection. It's patched two
places
because
+# adodbapi.__init__ promotes adodbapi.adodbapi.Connection
to package
scope
Database.Connection = Connection
+Database.adodbapi.Connection = Connection
origCVtoP = Database.convertVariantToPython
def variantToPython(variant, adType):
 -43,6
+47,7 
return int(res) # If float but int, then int.
return res
Database.convertVariantToPython = variantToPython
+Database.adodbapi.convertVariantToPython = variantToPython
class DatabaseWrapper:
def __init__(self):
Kent
PS I tried submitting this as a patch in the tracker but I
didn't see
any 'attach file' button...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Problem and fix with ado_mssql |

|
2006-02-27 23:38:21 |
On Feb 28, 2006, at 5:48 AM, kent wrote:
> PS I tried submitting this as a patch in the tracker
but I didn't see
> any 'attach file' button...
The 'attach file' button will appear after you create the
ticket.
- Cheng
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Problem and fix with ado_mssql |

|
2006-02-28 01:17:08 |
Cheng Zhang wrote:
> On Feb 28, 2006, at 5:48 AM, kent wrote:
>
> > PS I tried submitting this as a patch in the
tracker but I didn't see
> > any 'attach file' button...
>
> The 'attach file' button will appear after you create
the ticket.
Ah...thanks. The patch is now in ticket 1412.
Kent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Problem and fix with ado_mssql |

|
2006-02-28 01:35:13 |
On 2/27/06, kent <kent37 tds.net> wrote:
>
> Cheng Zhang wrote:
> > On Feb 28, 2006, at 5:48 AM, kent wrote:
> >
> > > PS I tried submitting this as a patch in the
tracker but I didn't see
> > > any 'attach file' button...
> >
> > The 'attach file' button will appear after you
create the ticket.
>
> Ah...thanks. The patch is now in ticket 1412.
Kent, after previously applying the patch you describe (I'd
found and
fixed that myself a while ago), I found a bunch of other
failing test
cases. Cheng's approach on 1258 is more successful and is
also
cross-platform for the client import, so we're planning to
go that
way.
I'm currently (as in, today) working on Cheng's ticket (
http://code
.djangoproject.com/ticket/1258
), so if you don't mind using pymssql (which uses TDS
underneath),
that should be in on magic-removal branch within a day or
so. We're
not exactly sure when magic will merge back to trunk, but
Real Soon
Now.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|