Updating a filename's counter value failed each time

MRAB python at mrabarnett.plus.com
Mon Jun 17 13:40:28 EDT 2013


On 17/06/2013 17:39, Simpleton wrote:
> Hello again, something simple this time:
>
> After a user selects a file from the form, that sleection of his can be
> found form reading the variable 'filename'
>
> If the filename already exists in to the database i want to update its
> counter and that is what i'm trying to accomplish by:
>
> -----------
> if form.getvalue('filename'):
> 	cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit =
> %s WHERE url = %s''', (host, lastvisit, filename) )
> -----------
>
> For some reason this never return any data, because for troubleshooting
> i have tried:
>
> -----------------
> data = cur.fetchone()
>
> if data:
> 	print("something been returned out of this"_
> ----------------
>
> Since for sure the filename the user selected is represented by a record
> inside 'files' table why its corresponding counter never seems to get
> updated?
>
You say "for sure". Really? Then why isn't it working as you expect?

When it comes to debugging, """assumption is the mother of all
****-ups""" [insert relevant expletive for "****"].

Assume nothing.

What is the value of 'filename'?

What are the entries in the 'files' table?

Print them out, for example:

     print("filename is", ascii(filename))

or write them into a log file and then look at them.




More information about the Python-list mailing list