Here's an example that doesn't work:
stmt = '''
SELECT `date_new`, `event`
FROM `events`
WHERE `date_new` > TIMESTAMP(DATE_SUB(NOW(), INTERVAL %(days)s day))
'''
args = {'days': 30}
c.execute(stmt, args)
which gives me an error: ValueError: Could not process parameters.
A query that includes something like this:
WHERE quantity = %(qty)s
works just fine.
I did find this: What parts of a SQL query are allowed to be parameterized? But that leaves the question in the specific example above: What about the argument to INTERVAL makes it not work?
I have found lots of documentation about the basics of using pyformat variables/parameters. I think part of the problem I'm having finding something is that it involves the intersection of Python and MySQL via mysql.connector.
I'd like a pointer to some documentation about what parts of queries allow their use and what ones don't, specifically for MySQL.
%s.INTERVALexpressions.python3 -m pip show mysql-connector-pythonoutput?