|
@@ -8,12 +8,15 @@ class DatabaseInfo:
|
|
|
self._conn = pyodbc.connect("DSN=GC;UID=sa;PWD=Mffu3011#")
|
|
|
|
|
|
def databases(self):
|
|
|
- res = self._conn.execute("SELECT name FROM master.sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')")
|
|
|
+ res = self._conn.execute(
|
|
|
+ "SELECT name FROM master.sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')"
|
|
|
+ )
|
|
|
return res.fetchall()
|
|
|
|
|
|
def table_size(self, database):
|
|
|
self._conn.execute(f"USE {database}")
|
|
|
- res = self._conn.execute("""
|
|
|
+ res = self._conn.execute(
|
|
|
+ """
|
|
|
SELECT db_name() as DatabaseName, s.name AS SchemaName, t.name AS TableName, p.rows AS RowCounts,
|
|
|
SUM(a.total_pages) * 8 AS TotalSpaceKB,
|
|
|
SUM(a.used_pages) * 8 AS UsedSpaceKB,
|
|
@@ -27,5 +30,6 @@ class DatabaseInfo:
|
|
|
LEFT OUTER JOIN sys.dm_db_index_usage_stats AS u ON t.object_id = u.object_id
|
|
|
WHERE (t.name NOT LIKE 'dt%') AND (t.is_ms_shipped = 0) AND (i.object_id > 255)
|
|
|
GROUP BY s.name, t.name, p.rows
|
|
|
- ORDER BY 1, 2, 3""")
|
|
|
+ ORDER BY 1, 2, 3"""
|
|
|
+ )
|
|
|
return res.fetchall()
|