Karen Tracey escribió: > On Mon, Jan 19, 2009 at 12:40 PM, Ramiro Morales <cra...@gmail.com > <mailto:cra...@gmail.com>> wrote: > > > On Mon, Jan 19, 2009 at 3:15 PM, Matias Surdi <matiassu...@gmail.com > <mailto:matiassu...@gmail.com>> wrote: > > > > The curious thing here, is that the above query works perfect > running it > > directly through sqlite3. > > > > From what I have seen by reading DB backend source code, Django > cursor's > execute() method supports only the printf-like parmeter maker style > with a list > or tuple of actual parameters. > > If you want to use the pyformat parameter marking style (as described > in PEP 249), > you' ll need to use the native DB-API driver API as you've already > discovered. > > > I didn't look at any code, I just tried a similar query on my own DB, > using current 1.0.X branch code: > > k...@lbox:~/software/web/xword$ python manage.py shell > Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole) > >>> from django.db import connection > >>> query = "SELECT * FROM Authors WHERE Author = %(name)s" > >>> parms = {'name': 'Manny Nosowsky'} > >>> cursor = connection.cursor() > >>> data = cursor.execute(query, parms) > >>> data > 1L > >>> cursor.fetchall() > ((4L, u'Manny Nosowsky', u'No', u''),) > >>> > >>> > > That's using MySQL as the DB, so perhaps it is backend-specific? The > only thing I needed to do to make the example shown originally work is > remove the quotes (and use table/column/parm names that exist in my DB). > > Karen > > >
Yes, maybe it's just a problem with sqlite, which is te backend I'm using.I'll try with mysql later. Is this a bug? should it be reported as a ticket? --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---