Feb-26-2019, 01:31 PM
Hello,
Can you help me rewrite this function, which when iam using 'pymysql' conncector works normally, it does not when iam using 'bottle_pymysql'
- απόκρυψη αναφερόμενου κειμένου -
pagehit = cur.fetchone()[0] does not work
while reffering by name of the field
pagehit = cur.fetchone()['hits'] does work.
Please help me write the baove function in a similar way.
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 For some reason in 'bottle-pymysql'pagehit = cur.fetchone()[0] does not work
while reffering by name of the field
pagehit = cur.fetchone()['hits'] does work.
Please help me write the baove function in a similar way.
