How to add a current string into an already existing list

Nick the Gr33k nikos.gr33k at gmail.com
Sat Nov 2 07:58:50 EDT 2013


Trying to add the current filename into the existent 'downloads' column
Somehow i don't think i just use the plus sign into an existing column.
We don't try to add numbers here but add an extra string to an already 
existing array of strings(list).

======================================================
# update specific torrent's download counter
cur.execute('''UPDATE files SET hits = hits + 1, host = %s, city = %s, 
lastvisit = %s WHERE torrent = %s''', (host, city, lastvisit, filename) )
		
# update specific visitor's download record
cur.execute('''UPDATE visitors SET downloads = downloads + %s WHERE host 
= %s''', (filename, host) )
======================================================




Retrieval time for displaying purposes:
======================================================
downloads = []
if cur.rowcount:
	for torrent in data:
		downloads = ', '.join( torrent )
	else:
		downloads = 'Κανένα κατέβασμα ταινίας'
		
# add this visitor entry into database (visits is unique)
cur.execute('''INSERT INTO visitors (counterID, refs, host, city, 
useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, 
%s)''', (cID, refs, host, city, useros, browser, visits, downloads) )
======================================================

Is this correct, personally i would just prefer:

for torrent in data:
		downloads.append( torrent )

Can you tell me the differenced on these two ways?

Aren't the result of both of them a list?




More information about the Python-list mailing list