# Path: HPCStats/Exceptions.py
# class HPCStatsDBIntegrityError(HPCStatsException):
# 
#     """Class for DB intregrity errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsDBIntegrityError, self).__init__(msg)
# 
# class HPCStatsRuntimeError(HPCStatsException):
# 
#     """Class for runtime errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsRuntimeError, self).__init__(msg)


import psycopg2
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError
                 self.database["dbuser"],
                 "XXXXXXXXXX" )

    def bind(self):
        """ Connection to the database """
        conn_str = "host = %(dbhostname)s " \
                   "dbname= %(dbname)s " \
                   "user= %(dbuser)s " \
                   "password= %(dbpassword)s" \
                     % (self.database)
        try:
            self._conn = psycopg2.connect(conn_str)
        except psycopg2.OperationalError, err:
            raise HPCStatsRuntimeError( \
                    "Error while trying to connect on HPCStats DB: %s" \
                      % (err))
        self.cur = self._conn.cursor()
        return self.cur, self._conn

    def execute(self, req, params):
        """Execute SQL request req with params. Raises HPCStatsDBIntegrityError
           in case of problem.
        """

        try:
            self.cur.execute(req, params)
        except ( psycopg2.DataError,
                 psycopg2.ProgrammingError,
                 psycopg2.IntegrityError,
                 psycopg2.OperationalError ), err:

# Path: HPCStats/Exceptions.py
# class HPCStatsDBIntegrityError(HPCStatsException):
# 
#     """Class for DB intregrity errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsDBIntegrityError, self).__init__(msg)
# 
# class HPCStatsRuntimeError(HPCStatsException):
# 
#     """Class for runtime errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsRuntimeError, self).__init__(msg)


# Path: HPCStats/DB/HPCStatsDB.py
import psycopg2
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

                 self.database["dbuser"],
                 "XXXXXXXXXX" )

    def bind(self):
        """ Connection to the database """
        conn_str = "host = %(dbhostname)s " \
                   "dbname= %(dbname)s " \
                   "user= %(dbuser)s " \
                   "password= %(dbpassword)s" \
                     % (self.database)
        try:
            self._conn = psycopg2.connect(conn_str)
        except psycopg2.OperationalError, err:
            raise HPCStatsRuntimeError( \
                    "Error while trying to connect on HPCStats DB: %s" \
                      % (err))
        self.cur = self._conn.cursor()
        return self.cur, self._conn

    def execute(self, req, params):
        """Execute SQL request req with params. Raises HPCStatsDBIntegrityError
           in case of problem.
        """

        try:
            self.cur.execute(req, params)
        except ( psycopg2.DataError,
                 psycopg2.ProgrammingError,
                 psycopg2.IntegrityError,
                 psycopg2.OperationalError ), err:

            raise HPCStatsDBIntegrityError( \