Sunday, June 26, 2011

sageMath Myth(TV) plot

here's a sagemath plot of disk usage from my MythTV:



generated to find out the show taking up the most space...

here's a bare sql query to show in text



select title,
sum(filesize)
from mythconverg.recorded
group by title
order by sum(filesize) desc ;






and my actual sage script:



import sys

##did not install MySQLdb into sage, only default location, so had to add
sys.path.append('/usr/lib/python2.7/site-packages/')

import MySQLdb

print "MythTV File sizes"

import _mysql
db=_mysql.connect(host="localhost",user="myuser",passwd="mypassword",
db="mythconverg")

db.query(""" select @rn:=@rn+1 rn, sum(filesize)/1024/1024 from (select @rn:=0)r, mythconverg.recorded group by title order by sum(filesize) desc""")

r=db.store_result()
scatter_plot(r.fetch_row(0))



No comments: