Updating a filename's counter value failed each time
John Gordon
gordon at panix.com
Mon Jun 17 13:40:26 EDT 2013
In <kpne3k$1066$1 at news.ntua.gr> Simpleton <support at superhost.gr> writes:
> 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"_
> ----------------
An UPDATE statement isn't a query. There are no results to be fetched.
If you want to get results, execute a query (usually a SELECT.)
Also, that print statement is an obvious syntax error. Please post
the actual code you're running; don't type it in from memory.
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list