- status: open --> closed
mysql.connector requires parameterized queries in version 9.0.0 and later. These are non-optional. Instead of escaping arguments,
as shown below:
def SQLFindSeriesId(target):
CNX = MYSQL_CONNECTOR()
target = CNX.DB_ESCAPE_STRING(target)
query = "select series_id from series where series_title='%s'" % (target)
CNX.DB_QUERY(query)
You are now required to parameterize arguments, by doing something along these lines:
def SQLFindSeriesId(target):
CNX = MYSQL_CONNECTOR()
query = "select series_id from series where series_title= %s "
CNX.cursor.execute(query, (target,))
This is Part I of changes to SQLparsing.py to mitigate observed script crashes. With these changes all unittests
pass, as well as biblio_compare (which compares biblio script output between isfdb.org and isfdb2.org) and edit_compare
(which compares edit script output between isfdb.org and isfdb2.org). This tests were also run on a 3rd system at
home, running python3.12.3 and mysql.connector 9.6.0.
We now have three different eras of mysql connectors to support. Python2 support requires keeping MySQLdb semantics, while Python3 requires moving to mysql.connector, with a different set of semantics. This was accomplished through the CNX class. Now we need to support pre and post 9.0.0 versions of myql.connector. This is handled via the _param_queries global, set in SQLparsing.py. This is automaically set via:
import mysql.connector
_connector_version = mysql.connector.__version__
if _connector_version[0] == '9':
_param_queries = 1
As such, the old non-parameterized queries still existin the code base, and tested against all three eras of MySQL connectors. Summary of changes in this SR:
1] The following routines were modified to use parameterized queries in SQLparsing.py:
2] Support for localhost to isfdb2 comparisons in biblio_compare and edit_compare. This was performed as part of the bringup on a recent version of linux configured as a private home server.
3] Support for localhost/private server in unit tests. This covers the lack of a Wiki or user logins. Imapcts these tests:
Anonymous