2014-11-24 20:50:58 -05:00

28 lines
644 B
Python

import sqlite3
conn = sqlite3.connect('default.db')
c = conn.cursor()
switched = [ 0, 0 ]
no_swich = [ 0, 0 ]
total = [ 0, 0 ]
c.execute( "SELECT * FROM games " )
result = c.fetchall()
for i in result:
if int( i[ 2 ] ) == 1:
# switched
switched[0] += 1
switched[1] += int( i[3] )
else:
# not switched
no_swich[0] += 1
no_swich[1] += int( i[3] )
total[0] += 1
total[1] += int( i[3] )
conn.commit()
c.close()
print( "switched", switched, "not switched", no_swich, "total", total)
print( 'switched', ( switched[1]/switched[0] )*100, "% not switched", ( no_swich[1]/no_swich[0] )*100, "% all", ( total[1]/total[0] )*100, "%" )