35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
##############################################################################
|
|
#
|
|
# 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
|
|
"""
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from ..stats import AbstractStats
|
|
|
|
class PostgreSQLStats(AbstractStats):
|
|
|
|
def get_object_count(self):
|
|
"""Returns the number of objects in the database"""
|
|
# do later
|
|
return 0
|
|
|
|
def get_db_size(self):
|
|
"""Returns the approximate size of the database in bytes"""
|
|
def callback(_conn, cursor):
|
|
cursor.execute("SELECT pg_database_size(current_database())")
|
|
return cursor.fetchone()[0]
|
|
return self.connmanager.open_and_call(callback)
|