I have some code that needs to escape strings to generate a SQL query for MariaDB. I'm using the mysqlclient module. My code uses escape_string to do this. However, in current versions of mysqlclient the escape_string function has been removed. For instance, with mysqlclient 2.1.0 one gets an ImportError on escape_string:
>>> from MySQLdb import escape_string
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'escape_string' from 'MySQLdb' (/home/jhaiduce/.local/lib/python3.10/site-packages/MySQLdb/__init__.py)
It seems escape_string was removed deliberately in a pull request that was merged on October 19th this year, see https://github.com/PyMySQL/mysqlclient/pull/511. Not sure why this was done, but I still need to escape a string to construct my query. Can anyone tell me another way to do this?