mysqlclient icon indicating copy to clipboard operation
mysqlclient copied to clipboard

Feature request: Add mogrify to Cursor

Open steveteahan opened this issue 5 years ago • 4 comments

The reasoning behind this change was already covered in PyMySQL: https://github.com/PyMySQL/PyMySQL/pull/330

I was wondering if there was any chance that this change would be considered for mysqlclient? I didn't see it mentioned in any of the previous issues. Having this consistent interface between PyMySQL and mysqlclient would make it simpler to support both projects.

Thank you for your time!

steveteahan avatar Jan 16 '21 15:01 steveteahan

I have what I believe to be an initial working version of this. I need to expand the testing, but I'll hold off until I get a sense for whether this would be considered as a feature or not.

steveteahan avatar Jan 16 '21 17:01 steveteahan

It makes sense. Compatibility between mysqlclient and PyMySQL (except low level APIs provided by MySQLdb._mysql module) is welcome.

methane avatar Jan 18 '21 06:01 methane

FWI, PyMySQL and mysqlclient provides Cursor._executed attribute. I think this can be a public API (e.g. Cursor.last_executed_query) and both mysqlclient and PyMySQL implemented it.

methane avatar Jan 18 '21 06:01 methane

Thank you for the feedback, @methane. I was also thinking about exposing _executed as part of the public API. I think that having both could be useful depending on whether the query is needed before or after it is executed. The Cursor.last_executed_query change seems trivial at the surface, so I can probably get a PR together for that too.

steveteahan avatar Jan 18 '21 12:01 steveteahan