/[glsr]/trunk/site/stat.py
Gentoo

Contents of /trunk/site/stat.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (show annotations) (download) (as text)
Wed Sep 21 06:32:49 2005 UTC (12 years, 2 months ago) by hadfield
File MIME type: text/x-python
File size: 896 byte(s)
started implementing admin panel statistics
1 # Copyright 2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 #
4
5 """Methods for obtaining repo statistics."""
6
7 __revision__ = "$Id$"
8 __authors__ = ["Scott Hadfield <hadfield@gentoo.org>",
9 "Ian Leitch <port001@gentoo.org>"]
10 __modulename__ = "stat"
11
12 from glsr.setup import config
13 from glsr.core.db.mysql import SQLdb
14
15 def dbsize():
16 """Returns the size of the database in bytes."""
17
18 result = SQLdb(config.db).query("SHOW TABLE STATUS", fetch = "all")
19
20 dbsize = 0
21 for row in result:
22 dbsize += row["Data_length"] + row["Index_length"]
23
24 return str(dbsize)
25
26 def count(table):
27 """Returns the total number of rows in the specified table."""
28
29 result = SQLdb(config.db).query(
30 "SELECT count(*) FROM %s%s" % (config.db["prefix"], table),
31 fetch = "one")
32
33 return str(result["count(*)"])

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20