Opened 7 years ago

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


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)

Attachments (0)

Change History (1)

comment:1 Changed 7 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?

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.