I am using the python mysql connector with sqlalchemy. I try to use this code to truncate a table:
session = db.Session()
session.execute('''TRUNCATE TABLE Orders''')
session.commit()
But I receive this warning.
python3.8/site-packages/mysql/connector/connection_cext.py:506: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats self._cmysql.query(query,
I receive this issue also for other queries. The provided example is just for being an example.
Why exactly do I get this warning?
Why exactly do I get this warning?
Probably you are using mysql-connector before version 1.4.3 when they added PY_SSIZE_T_CLEAN macros
Also, some modules like unittest by default shows DeprecationWarning, PendingDeprecationWarning, ResourceWarning and ImportWarning even if they are ignored by default.
More info:
Starting from Python 3.8 it will Raise a warning for # use without PY_SSIZE_T_CLEAN in Python C API if Macros PY_SSIZE_T_CLEAN was not defined before including Python.h.
https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers
For all # variants of formats (s#, y#, etc.), the type of the length argument (int or Py_ssize_t) is controlled by defining the macro PY_SSIZE_T_CLEAN before including Python.h. If the macro was defined, length is a Py_ssize_t rather than an int. This behavior will change in a future Python version to only support Py_ssize_t and drop int support. It is best to always define PY_SSIZE_T_CLEAN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With