Opened 17 years ago

Closed 17 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: dev
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

Description

In file /usr/lib/python2.4/site-packages/django/db/backends/sqlite3/base.py 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 by Simon G. <dev@…>, 17 years ago

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