OK, so , as I might have expected, the weewx mysql layer replaces '?' with the '%s' parameter marker.
And there is a specific comment about handling timespan tuples (weedb/mysql.py) just before it calls cursor.execute. So, back to what Vince said - you'll need the original error message. The suggested replacement is certainly the wrong way to go. On Wednesday, 24 August 2022 at 12:14:34 pm UTC+10 Cameron D wrote: > The problem is you are combining a python formatted string with text for a > parameterised query. > For whatever bizarre reason, the python sql specs allow different database > interfaces to use different parameter indicators. Mysql uses "%s" while > sqlite uses "?". > > For a mysql query you obviously can't also add a python string format in > the old (%) style, as the "%s" will be grabbed early. > > I don't know how weewx handles the different query parameters. > > On Wednesday, 24 August 2022 at 3:02:26 am UTC+10 [email protected] wrote: > >> A user of my extension weewx-GTS reported an error in a call of genSql() >> from manager.py. The original line is: >> >> for _result in db_manager.genSql( >> "SELECT `dateTime`,`usUnits`," >> "`outTemp`,`outHumidity`,`pressure`" >> "from %s WHERE dateTime>? AND dateTime<=?" >> "ORDER BY `dateTime`" >> % db_manager.table_name,timespan): >> ... >> >> He claimed that he had to change that line for use with MySQL to: >> >> for _result in db_manager.genSql( "SELECT >> `dateTime`,`usUnits`,`outTemp`,`outHumidity`,`pressure` from %s WHERE >> dateTime> %d AND dateTime<= %d ORDER BY `dateTime`" % >> (db_manager.table_name,timespan.start,timespan.stop)): >> >> Those 2 question marks are always used throughout WeeWX. So I do not >> understand why it causes an error in this case. >> >> Some hints? >> >> -- You received this message because you are subscribed to the Google Groups "weewx-development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/c1370e10-2c54-47d8-b3bc-539f6182a6b8n%40googlegroups.com.
