[Python-Dev] Bug in the DELETE statement in sqlite3 module
Guido van Rossum
guido at python.org
Wed Jun 15 12:33:47 EDT 2016
A point of order: it's not necessary to post three separate "this is the
wrong list" replies. In fact the optimal number is probably close to zero
-- I understand we all want to be helpful, and we don't want to send
duplicate replies, but someone who posts an inappropriate question is
likely to try another venue when they receive no replies, and three replies
to the list implies that some folks are a little too eager to appear
helpful (while reading the list with considerable delay). When the OP pings
the thread maybe one person, preferably someone who reads the list directly
via email from the list server, could post a standard "wrong list" response.
On Wed, Jun 15, 2016 at 8:29 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 15 June 2016 at 07:40, ninostephen mathew <ninosm12 at gmail.com> wrote:
> > Respected Developer(s),
> > while writing a database module for one of my applications in python I
> > encountered something interesting. I had a username and password field
> in my
> > table and only one entry which was "Admin" and "password". While
> > I purposefully deleted that record. Then I ran the same statement again.
> > my surprise, it got execute. Then I ran the statement to delete the user
> > "admin" (lowercase 'a') which does not exist in the table. Surprisingly
> > again is got executed even though the table was empty. What I expected
> > an error popping up. But nothing happened. I hope this error gets fixed
> > soon. The code snippet is given below.
> > self.cursor.execute(''' DELETE FROM Users WHERE username =
> > ?''',(self.username,))
> First of all, this list is for the discussions about the development
> of Python itself, not for developing applications with Python. You
> should probably be posting to python-list instead.
> Having said that, this is how SQL works - a DELETE statement selects
> all records matching the WHERE clause and deletes them. If the WHERE
> clause doesn't match anything, nothing gets deleted. So your code is
> working exactly as I would expect.
> Python-Dev mailing list
> Python-Dev at python.org
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev