mysql.result.Result

Package mysql :: Module result :: Class Result |
[hide private]
[frames] | no frames]

# Class Result

    object --+
             |
            Result

Query result object.

This object provides a method to retrieve the results from a query using the mysql.connection.Connection.execute method.

Typically you call fetch_row until it raises mysql.exceptions.No_More_Rows to retrieve the data. You can also iterate over the result object to retrieve the data, or call fetch_all_rows to fetch all the data at once.

The type of data returned depends on the field type and the conversion routines defined when you created the mysql.connection.Connection object. See mysql.conversion for more detail about data conversion and the default conversions available.

If you specified `store_result` as False (the default) to the `execute` method, then the results are buffered on the server side. You can have only 1 live Result object per connection in this case. If you attempt to create another result object, then your old result object will be forcefully closed.

Attempting to access the result object after it is closed will result in raising mysql.exceptions.Result_Closed_Error. Attempting to access the result object after the connection is closed will result in raising mysql.exceptions.Not_Connected_Error.

The `__len__` method is also implemented, but you should read the num_rows docstring for limitations.

Instance Methods | [hide private]
`` | __iter__(x) iter(x)
`` | __len__(x) len(x)
`` | __new__(T, S, ...) Returns a new object with type S, a subtype of T...
`` | close(...) Release the internally buffered result data.
`` | closed(...) Check if the result is closed.
`` | fetch_all_rows(...) Return all remaining rows in the result.
`` | fetch_container(...) Fetch one row of data into a container.
`` | fetch_row(...) Return one row from the result.
`` | fields(...) Return all field types.
`` | next(x) Returns the next value, or raise StopIteration...
`` | num_fields(...) Returns the number of fields in the result.
`` | num_rows(...) Return the number of rows in the result.
`` | row_seek(...) Set the current row position.
`` | row_tell(...) Indicate the current row position.
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables | [hide private]
`` | __pyx_vtable__ = `<PyCObject object at 0x847ff98>`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __iter__(x) |
iter(x)

### __len__(x) (Length operator) |
len(x)

### __new__(T, S, ...) |
    Returns:
        a new object with type S, a subtype of T
Overrides: object.__new__

### close(...) |
Release the internally buffered result data. This will release any internally held information about the result. This will render the result object useless. This is automatically called when the object is deleted. If the result is already closed, this does nothing. Further attempts to use the result object will raise mysql.exceptions.Result_Closed_Error.

### closed(...) |
Check if the result is closed. This can be used to check if the result has been closed with the close method. This is the only method you may call (besides close) on a closed Result object. Returns: Returns True if this Result object is closed, False if it is still live.

### fetch_all_rows(...) |
Return all remaining rows in the result. This will return a list of rows (each row being a tuple itself). Returns: Returns a list of rows. Returns an empty list if there are no more rows. Raises: `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### fetch_container(...) |
Fetch one row of data into a container. This will fetch one row of data. It will set the output of each column into the container using `setattr`. If a column name is aliased with "AS", then the aliased name will be used for setting the value in the container. Parameters: `container` - The object to set the output into. Raises: `mysql.exceptions.No_More_Rows` - There are no more rows left. `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### fetch_row(...) |
Return one row from the result. Returns: Returns a tuple that is the row values. Raises: `mysql.exceptions.No_More_Rows` - There are no more rows left. `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### fields(...) |
Return all field types. Returns: Returns a list of Field instances that describe the columns in a query. Raises: `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### next(x) |
    Returns:
        the next value, or raise StopIteration

### num_fields(...) |
Returns the number of fields in the result. Returns: Returns an integer of the number of fields. Raises: `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### num_rows(...) |
Return the number of rows in the result. Note The behavior of this method depends on whether `store_result` was set in the call to `execute`. If `store_result` was False, then this only returns the correct result after all the rows have been fetched. If it was True, then it will always return the correct result. Returns: Returns the number of rows in the result. Raises: `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### row_seek(...) |
Set the current row position. Note This is only available if the result was stored by passing True to the `store_result` parameter in the `execute` call. Parameters: `offset` - An offset object returned from row_tell or an integer of an explicit row number (starting at zero). If it is a number, it must be a number from 0 to `num_rows()-1`. Returns: Returns the previous row offset as an opaque object. Raises: `mysql.exceptions.Result_Unbuffered_Error` - The result is in unbuffered mode (`store_result` was set to False). `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

### row_tell(...) |
Indicate the current row position. Note This is only available if the result was stored by passing True to the `store_result` parameter in the `execute` call. It returns an opaque object to be used with row_seek. Raises: `mysql.exceptions.Result_Unbuffered_Error` - The result is in unbuffered mode (`store_result` was set to False). `mysql.exceptions.Commands_Out_Of_Sync` - Commands were executed in an improper order. `mysql.exceptions.Out_Of_Memory` - Out of memory. `mysql.exceptions.Server_Gone_Error` - The MySQL server has gone away. `mysql.exceptions.Server_Lost` - The connection to the server was lost during the query. `mysql.exceptions.Unknown_Error` - An unknown error occurred. `mysql.exceptions.Result_Closed_Error` - close has been called on this object. `mysql.exceptions.Not_Connected_Error` - The connection has been closed.

Class Variable Details | [hide private]

    ### __pyx_vtable__ Value:
        <PyCObject object at 0x847ff98>