################################################################################ Copyright (c) 2009 Zope Foundation and Contributors.# All Rights Reserved.## This software is subject to the provisions of the Zope Public License,# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS# FOR A PARTICULAR PURPOSE.###############################################################################"""Stats implementations"""importabcfromzope.interfaceimportimplementerfrom.._compatimportABCfrom.interfacesimportIDBStatsfrom._utilimportDatabaseHelpersMixinfrom.schemaimportSchemafrom.sqlimportfunc
[docs]defget_object_count(self):"""Returns the approximate number of objects in the database"""conn,cursor=self.connmanager.open_for_load()try:self._get_object_count_query.execute(cursor)returncursor.fetchone()[0]finally:self.connmanager.close(conn,cursor)
[docs]@abc.abstractmethoddefget_db_size(self):"""Returns the approximate size of the database in bytes"""raiseNotImplementedError()
[docs]deflarge_database_change(self):""" Call this when the database has changed substantially, and it would be a good time to perform any updates or optimizations. """