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/bc46ecb9-0a1a-4dee-aafc-7b7eee4d8fc4n%40googlegroups.com.
