Opened 12 years ago

Closed 12 years ago

#3962 closed (invalid)

sqlite3 backend does not allow '%i' in cursor.execute

Reported by: anonymous Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords: sqlite int integer %i
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In file /usr/lib/python2.4/site-packages/django/db/backends/sqlite3/ is sais:

def convert_query(self, query, num_params):
    return query % tuple("?" * num_params)

This raises a TypeError in cases like: "SELECT * FROM table WHERE id = %i" % tuple("?" * 1), because '?' is no int.

A workaround for this special case could be

return query.replace('%i', '%s') % tuple("?" * num_params)

Change History (1)

comment:1 Changed 12 years ago by Simon G. <dev@…>

Resolution: invalid
Status: newclosed

When does this occur? will this only happen when using custom SQL?

Note: See TracTickets for help on using tickets.
Back to Top