示例#1
0
    def _getNZDS(self, sql, bv=[], po='SEL'):
        self.log.debug('qry = %s' % sql)
        cs = getDSConnStr('NZODBC', self.ib.user, self.ib.pwd, self.ib.dbserver, self.ib.db)
        dbh = NZODBC(cs, self.log)
        rc  = dbh.connToDB () 
        if rc != 0 : 
            self.log.error('Could not connect to the DB rc = %s ' % rc)
            return None
        
        if po == 'SEL': r = dbh.runQry(sql)
        else          : r = dbh.exeQry(sql,bv)

        dbh.closeDBConn()
        return r
示例#2
0
 def connToDB(self):
     r = 1
     sql = 'select current_timestamp'
     self.logger.debug('qry = %s' % sql)
     cs = getDSConnStr('NZODBC',self.ib.db_user,self.ib.db_pwd,self.ib.db_server,self.ib.db_name)
     self.logger.debug('ConnStr %s' % cs)
     dbh = NZODBC(cs,self.logger)
     if dbh.connToDB() != 0 : return r
     
     rs = dbh.runQry(sql)
     if rs is not None and len(rs) > 0 :  
         r = 0
         self.logger.debug("rs = %s" % rs[0][0])
     
     dbh.closeDBConn()
     return r