#!/usr/bin/python

from MySQLdb import connect
from time import time

cursor = connect(read_default_group='client').cursor()
#read_default_file='/mit/sql/.my.cnf').cursor()
cursor.execute("SHOW STATUS WHERE Variable_name IN ('Queries','Uptime')")
stats = dict(cursor.fetchall())
cursor.execute("SHOW VARIABLES LIKE 'hostname'")
host = cursor.fetchone()[1]

cursor.execute('USE `sql+stat`')
cursor.execute('INSERT INTO questions VALUES (NOW(), %s, %s, %s)',
               (host, stats['Uptime'], stats['Queries']))
