Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92014766
bibstat.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 16, 15:25
Size
3 KB
Mime Type
text/x-c
Expires
Mon, Nov 18, 15:25 (2 d)
Engine
blob
Format
Raw Data
Handle
22363672
Attached To
R3600 invenio-infoscience
bibstat.wml
View Options
## $Id$
## BibStat utility to report some interesting numbers on CDSware bibliographic record set.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
## start Python:
<protect>#!</protect><PYTHON>
<protect>## $Id$</protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
"""
BibStat reports some interesting numbers on CDSware bibliographic record set.
"""
## fill config variables:
dbhost = "<DBHOST>"
dbname = "<DBNAME>"
dbuser = "<DBUSER>"
dbpass = "<DBPASS>"
## okay, rest of the Python code goes below
#######
## version number:
__version__ = "$Id$"
## import interesting modules:
try:
from marshal import loads,dumps
from zlib import compress,decompress
from string import split,translate,lower,upper
import getopt
import string
import os
import re
import sys
import time
import MySQLdb
import urllib
import signal
import threading
import unicodedata
import traceback
import cStringIO
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
## cursor to MySQL database:
try:
db = MySQLdb.connect(host=dbhost, db=dbname, user=dbuser, passwd=dbpass)
cursor = db.cursor()
except StandardError, err:
Log(str(err),"Error")
sys.exit(1)
def escape_string(s):
"Escapes special chars in string. For MySQL queries."
return MySQLdb.escape_string(s)
def report_bibXXx_table_status(tablename):
"""Report stats for the table bibXXx 'tablename'."""
out = ""
query = "SHOW TABLE STATUS LIKE '%s'" % escape_string(tablename)
cursor.execute(query)
row = cursor.fetchone()
while row:
out += "%14s %17d %17d %17d" % (row[0], row[3], row[5], row[7]) # Name, Rows, Data_length, Max_data_length
row = cursor.fetchone()
return out
def report_bibwords_table_status(tablename):
"""Report stats for the table bibwordsX 'tablename'."""
out = ""
query = "SHOW TABLE STATUS LIKE '%s'" % escape_string(tablename)
cursor.execute(query)
row = cursor.fetchone()
while row:
out += "%14s %17d %17d %17d" % (row[0], row[3], row[5], row[7]) # Name, Rows, Data_length, Max_data_length
row = cursor.fetchone()
return out
def main():
"""Report stats on the CDSware bibliographic tables."""
print "%14s %17s %17s %17s" % ("TABLE", "ROWS", "DATA SIZE", "INDEX SIZE")
print "============== ================= ================= ================="
for i in range(0,10):
for j in range(0,10):
print report_bibXXx_table_status("bib%1d%1dx" % (i, j))
print report_bibXXx_table_status("bibrec_bib%1d%1dx" % (i, j))
for i in range(0,10):
print report_bibwords_table_status("bibwords%1d" % i)
print report_bibwords_table_status("bibwords%1dr" % i)
if __name__ == "__main__":
main()
Event Timeline
Log In to Comment