コード例 #1
0
ファイル: cursor.py プロジェクト: cclauss/Pythonista-4
    def _fetch_warnings(self):
        """
        Fetch warnings doing a SHOW WARNINGS. Can be called after getting
        the result.

        Returns a result set or None when there were no warnings.
        """
        res = []
        try:
            c = self._connection.cursor()
            cnt = c.execute("SHOW WARNINGS")
            res = c.fetchall()
            c.close()
        except StandardError as e:
            raise errors.InterfaceError, errors.InterfaceError(
                "Failed getting warnings; %s" % e), sys.exc_info()[2]

        if self._connection.raise_on_warnings is True:
            msg = '; '.join(["(%s) %s" % (r[1], r[2]) for r in res])
            raise errors.get_mysql_exception(res[0][1], res[0][2])
        else:
            if len(res):
                return res

        return None
コード例 #2
0
ファイル: protocol.py プロジェクト: Alwnikrotikz/open-hea
 def _handle_error(self, buf):
     """Raise an OperationalError if result is an error
     """
     try:
         err = ErrorResultPacket(buf)
     except errors.InterfaceError:
         raise
     else:
         raise errors.get_mysql_exception(err.errno,err.errmsg)
コード例 #3
0
ファイル: cursor.py プロジェクト: ekristen/mythboxee
        Returns a result set or None when there were no warnings.
        """
        res = []
        try:
            c = self.db().cursor()
            cnt = c.execute("SHOW WARNINGS")
            res = c.fetchall()
            c.close()
        except StandardError, e:
            raise errors.InterfaceError(
                "Failed getting warnings; %s" % e)
        
        if self.db().raise_on_warnings is True:
            msg = '; '.join([ "(%s) %s" % (r[1],r[2]) for r in res])
            raise errors.get_mysql_exception(res[0][1],res[0][2])
        else:
            if len(res):
                return res
            
        return None
    
    def _handle_eof(self, eof):
        self._have_result = False
        self.db().unread_result = False
        self._nextrow = (None, None)
        self._warning_count = eof['warning_count']
        if self.db().get_warnings is True and eof['warning_count']:
            self._warnings = self._fetch_warnings()
        self._set_more_results(eof['status_flag'])
        
コード例 #4
0
ファイル: protocol.py プロジェクト: ekristen/mythboxee
     """Raise an errors.Error when buffer has a MySQL error"""
     errno = errmsg = None
     try:
         buf = buf[5:]
         (buf,errno) = utils.read_int(buf, 2)
         if buf[0] != '\x23':
             # Error without SQLState
             errmsg = buf
         else:
             (buf,sqlstate) = utils.read_bytes(buf[1:],5)
             errmsg = buf
     except Exception, e:
         raise errors.InterfaceError("Failed getting Error information (%r)"\
             % e)
     else:
         raise errors.get_mysql_exception(errno,errmsg)
 
 def _recv_packet(self):
     """Getting a packet from the MySQL server"""
     buf = self.conn.recv()
     if buf[4] == '\xff':
         MySQLProtocol.raise_error(buf)
     else:
         return buf
     
 def _scramble_password(self, passwd, seed):
     """Scramble a password ready to send to MySQL"""
     hash4 = None
     try: 
         hash1 = sha1(passwd).digest()
         hash2 = sha1(hash1).digest() # Password as found in mysql.user()
コード例 #5
0
        Returns a result set or None when there were no warnings.
        """
        res = []
        try:
            c = self.db().cursor()
            cnt = c.execute("SHOW WARNINGS")
            res = c.fetchall()
            c.close()
        except StandardError, e:
            raise errors.InterfaceError(
                "Failed getting warnings; %s" % e)
        
        if self.db().raise_on_warnings is True:
            msg = '; '.join([ "(%s) %s" % (r[1],r[2]) for r in res])
            raise errors.get_mysql_exception(res[0][1],res[0][2])
        else:
            if len(res):
                return res
            
        return None
    
    def _handle_eof(self, eof):
        self._have_result = False
        self.db().unread_result = False
        self._nextrow = (None, None)
        self._warning_count = eof['warning_count']
        if self.db().get_warnings is True and eof['warning_count']:
            self._warnings = self._fetch_warnings()
        self._set_more_results(eof['status_flag'])
        
コード例 #6
0
        """Raise an errors.Error when buffer has a MySQL error"""
        errno = errmsg = None
        try:
            buf = buf[5:]
            (buf, errno) = utils.read_int(buf, 2)
            if buf[0] != '\x23':
                # Error without SQLState
                errmsg = buf
            else:
                (buf, sqlstate) = utils.read_bytes(buf[1:], 5)
                errmsg = buf
        except Exception, e:
            raise errors.InterfaceError("Failed getting Error information (%r)"\
                % e)
        else:
            raise errors.get_mysql_exception(errno, errmsg)

    def _recv_packet(self):
        """Getting a packet from the MySQL server"""
        buf = self.conn.recv()
        if buf[4] == '\xff':
            MySQLProtocol.raise_error(buf)
        else:
            return buf

    def _scramble_password(self, passwd, seed):
        """Scramble a password ready to send to MySQL"""
        hash4 = None
        try:
            hash1 = sha1(passwd).digest()
            hash2 = sha1(hash1).digest()  # Password as found in mysql.user()