Skip to content Skip to sidebar Skip to footer

Change Client_found_rows Flag In Django For Mysql-python (mysqldb)?

I have a problem with MySQL 5.5 INSERT ... ON DUPLICATE KEY UPDATE rows effected mismatch cursor.rowcount in a normal Django project According to doc: For INSERT ... ON DUPLICATE

Solution 1:

Okay, I found out how.

In django/db/backends/mysql/base.py there's

kwargs['client_flag'] = CLIENT.FOUND_ROWS
kwargs.update(settings_dict['OPTIONS'])

From the source code we could just change django project settings.py like this

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.',
        'NAME': '',                      
        'USER': '',                      
        'PASSWORD': '',                  
        'HOST': '', 
        'PORT': '',                      
        'OPTIONS': {
            'client_flag': 0
        }
    }
}

Post a Comment for "Change Client_found_rows Flag In Django For Mysql-python (mysqldb)?"