Пример #1
0
def check_sims_connection():
    if settings.DISABLE_REPORTING_DB:
        return
    from coredata.queries import SIMSConn, SIMSProblem
    db = SIMSConn()
    db.execute("SELECT descr FROM dbcsown.PS_TERM_TBL WHERE strm='1111'", ())
    if len(list(db)) == 0:
        raise SIMSProblem("Didn't get any data back from SIMS query.")
Пример #2
0
    def connect():
        """ Connect to a DB2 database.

            All subclasses of DB2_Query will use this database for queries. 

        """

        if settings.DISABLE_REPORTING_DB:
            raise SIMSProblem(
                "Reporting database access has been disabled in this deployment."
            )

        sims_user = settings.SIMS_USER
        sims_passwd = settings.SIMS_PASSWORD
        sims_db_name = settings.SIMS_DB_NAME
        sims_db_schema = settings.SIMS_DB_SCHEMA

        import ibm_db_dbi
        dbconn = ibm_db_dbi.connect(sims_db_name, sims_user, sims_passwd)
        cursor = dbconn.cursor()
        cursor.execute("SET SCHEMA " + sims_db_schema)
        DB2_Query.db = dbconn