[IronPython] Making adonet-dbapi's dbapi a drop-in replacement in django-mssql

Jeff Hardy jdhardy at gmail.com
Tue Oct 27 15:36:03 CET 2009


2009/10/27 Markus Törnqvist <mjt at nysv.org>:
> However, you construct this:
> command = self.connection.connection.CreateCommand()
>
> and start putting parameters in there, which makes me think I shouldn't
> do query % params after all, but that it executes it from a kind of a
> .net object or somesuch.

No, the query still needs to be changed to have the right parameter
markers so that ADO.NET knows where to insert the values. There should
be a line that sets  command.CommandText to the query. Then the
parameter values are added to the Parameters collection.

>
> I tried of course duplicating all the %s's in the query to ?s but that
> didn't help me out.

I think SQL Server's parameters are "@param", which means you'll have
to name them :). However, IMHO this should happen before the Django
layer passes the query to the MSSQL layer. mssql.py is supposed to be
a generic dbapi adapter, so I don't think adding a djngo-specific
conversion is a good idea.

>
> mssql.py is sort of weird.

No surprise, I haven't really had time to polish it.

>
> The connect() function returns generic_connect() from dbapi.generic.
>
> There is tuple replacement in mssql's class Cursor, method execute, which
> looks a lot more familiar.
>
> Now is there some chance that it's just broken, that it instantiates the
> wrong kind of cursor which calls, naturally, the wrong execute() method?

There's a very good chance that it's broken; I have no idea what state
it was in when I left it. If you get it working, patches are welcome.

- Jeff



More information about the Ironpython-users mailing list