Django

Code

Changeset 276

Show
Ignore:
Timestamp:
07/21/05 10:48:20 (3 years ago)
Author:
jacob
Message:

Refactor dictfetch* methods from mysql backend out into a seperate module; this is so that future db backends that need these functions can share them.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/db/backends/mysql.py

    r208 r276  
    66 
    77from django.core.db import base, typecasts 
     8from django.core.db.dicthelpers import * 
    89import MySQLdb as Database 
    910from MySQLdb.converters import conversions 
     
    4647            self.connection.close() 
    4748            self.connection = None 
    48  
    49 def _dict_helper(desc, row): 
    50     "Returns a dictionary for the given cursor.description and result row." 
    51     return dict([(desc[col[0]][0], col[1]) for col in enumerate(row)]) 
    52  
    53 def dictfetchone(cursor): 
    54     "Returns a row from the cursor as a dict" 
    55     row = cursor.fetchone() 
    56     if not row: 
    57         return None 
    58     return _dict_helper(cursor.description, row) 
    59  
    60 def dictfetchmany(cursor, number): 
    61     "Returns a certain number of rows from a cursor as a dict" 
    62     desc = cursor.description 
    63     return [_dict_helper(desc, row) for row in cursor.fetchmany(number)] 
    64  
    65 def dictfetchall(cursor): 
    66     "Returns all rows from a cursor as a dict" 
    67     desc = cursor.description 
    68     return [_dict_helper(desc, row) for row in cursor.fetchall()] 
    6949 
    7050def get_last_insert_id(cursor, table_name, pk_name):