#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import MySQLdb as mdb
import pprint

pp = pprint.PrettyPrinter(indent=4)


con = mdb.connect(host='localhost', user='root', passwd='', db='internet_news_analysis')
cur = con.cursor(mdb.cursors.DictCursor)

with con:

    cur.execute(
        """SELECT table_schema "internet_news_analysis",
        SUM(data_length + index_length) / (1024 * 1024) "Database Size in MB"
        FROM information_schema.TABLES GROUP BY table_schema"""
    )

    record = cur.fetchone()

    pp.pprint(record)



@@ -275,16 +275,19 @@
 execute(
+%22%22%22
 %0A       
@@ -287,19 +287,16 @@
         
-%22%22%22
 SELECT t
@@ -304,38 +304,22 @@
 ble_
-schema %22internet_news_analysis
+name AS %22Table
 %22,%0A 
@@ -329,11 +329,15 @@
     
-SUM
+ROUND((
 (dat
@@ -367,42 +367,38 @@
 ) / 
-(
 1024 
-*
+/
  1024)
- %22Database 
+, 2) AS %22
 Size 
-in 
+(
 MB
+)
 %22%0A  
@@ -437,38 +437,122 @@
 BLES
- GROUP BY table_schema%22%22%22%0A    
+%0A        WHERE table_schema = %22internet_news_analysis%22%0A        ORDER BY (data_length + index_length) DESC;%0A    %22%22%22
 )%0A%0A 

update db-size script