samedi 2 mai 2015

Python if statement skipping code even though condition is met

I am trying to check if an entry is already in the database and add the entry if it isn't but the if statement never runs even though the condition is met.

        userCurs.execute("SELECT EXISTS(SELECT 1 FROM images WHERE imageLink=?)", (image,))
        exists = userCurs.fetchone()
        if exists is None:
            addImage(userName,image,'','')
        else:
            print '--------> image skipped'
            print userCurs.fetchone()

I get this output:

--------> image skipped
None
--------> image skipped
None

and no entries are made to the database

Aucun commentaire:

Enregistrer un commentaire