Logo Search packages:      
Sourcecode: zope-kinterbasdbda version File versions

def zope-kinterbasdbda-1.0.orig::db::DB::query (   self,
  src = None,
  max_rows = 99999999 
)

	query - Execute a SQL statement.
	

Definition at line 173 of file db.py.

00173                                                 :
        """
      query - Execute a SQL statement.
      """

      self._register()
      if src == None or src == '':
         raise RuntimeError, "Empty SQL statement passed to the query method."

        rows    = []
      columns = []

        # If the SQL statement is EXECUTE PROCEDURE then invoke callproc,
      # otherwise invoke execute.

        if isProcedure(src):
            try:
                      tmp = self.cursor.callproc(src)
            except:
                  self.reInitCursor()
                  raise
                  
          rows.append(tmp)
        else:
            try:
            self.cursor.execute(src)
          except:
            self.reInitCursor()
            raise
            
          if self.cursor.description:
                rows = self.cursor.fetchmany(max_rows)

      if self.cursor.description:
          for n in self.cursor.description:
                current = { 'name' : '', 'type' : '', 'width' : 0, 'null' : 0 }

              name, type, dsize, isize, prec, scale, nulls = n

              current['name'] = name
              current['null'] = nulls
              
              if type == kinterbasdb.STRING:
                  current['type'] = 's'
              if type == kinterbasdb.BINARY:
                  current['type'] = 's'
                  current['width'] = isize
              if type == kinterbasdb.NUMBER:
                  current['type'] = 'n'
              if type == kinterbasdb.DATETIME:
                  current['type'] = 'd'


              if type == kinterbasdb.STRING:
                current['width'] = isize

                columns.append(current)

      return (columns, rows)




Generated by  Doxygen 1.6.0   Back to index