Opened 8 years ago

Closed 8 years ago

#3962 closed (invalid)

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

Reported by: anonymous Owned by: adrian
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: UI/UX:

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 Changed 8 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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

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