How to format a datetime MySQL database field to local using strftime()
vergos.nikolas at gmail.com
vergos.nikolas at gmail.com
Tue Feb 26 08:26:16 EST 2019
Can you help me rewrite this function, which when iam using 'pymysql' conncector works normally, it does not when iam using 'bottle_pymysql'
def coalesce( data ):
newdata = []
seen = {}
for host, ref, location, useros, browser, visits, hits, downloads, authuser in data:
# Here i have to decide how to group the rows together
# I want an html row for every unique combination of (host) and that hits should be summed together
key = host
if key not in seen:
newdata.append( [ [host], [ref], location, useros, browser, [visits], hits, [downloads], authuser ] )
seen[key] = len( newdata ) - 1 # Save index (for 'newdata') of this row
else: # This row is a duplicate row with a different referrer & visit datetime & torrent download
rowindex = seen[key]
newdata[rowindex][0].append( host )
newdata[rowindex][1].append( ref )
newdata[rowindex][5].append( visits )
newdata[rowindex][6] += hits
newdata[rowindex][7].append( downloads )
return newdata
More information about the Python-list
mailing list