correctly documented API for mysql FOUND_ROWS

Issue #3146 resolved
Mathieu Lacage created an issue

Hi,

The mysql connector sets by default the FOUND_ROWS bit in the client_flag set on each connection with the server. The documentation is explicit about this (good): http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html#rowcount-support

However, the documentation also says that it is possible to override this setting through the client_flag url argument. While it is indeed possible to set manually this client_flag argument, the FOUND_ROWS bit is set unconditionally in dialects/mysql/mysqlconnector.py

Hence, the attached patch (generated against git master) to allow callers who know what they are doing to override this default behavior in sqlalchemy

Comments (7)

  1. Mike Bayer repo owner

    I'd rather just change the docs to state that this is not an option. the FOUND_ROWS flag has no point in being changed IMHO.

    also, both mysqldb and mysqlconnector have a try/except around the whole operation, in the case of mysqldb this is probably due to very ancient versions of mysqldb and in the case of mysqlconnector I dont think there is any valid case for an except: there. The try/except should be removed.

    For the case where you really want to be able to affect this, I'd prefer an explicit option create_engine(..., count_matched_rows=True) that works equally for mysqldb, mysqlconnector, oursql, and the others (or raises a NotImplementedError for a DBAPI that doesn't provide for it). I'd need a pull request with unit tests for this.

  2. Log in to comment