Python sql problem, substitute in sql

period = "573"
SHYA= sqldf("select PPMONTH, REGION, WEARSEG, sum(uncal_value) as uncal_value \
           from Ftable where region in ("Shanghai") and WEARSEG in ("Men","Women")\
           and PPMONTH in (period) group by PPMONTH,WEARSEG")
           
sql in (period") 

PandaSQLException: (sqlite3.OperationalError) no such column: period [SQL: "select PPMONTH, REGION, WEARSEG, sum(uncal_value) as uncal_value-sharp-sharp-sharp 

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Jun.28,2022

Brother, the error report says:
no such column: period
means there is no such column.
do you not have a definition of period ? Is
or period a string? You didn't use double quotation marks?
or you can post the data. Let me see


SQL cannot write period directly. It should be converted to the value string corresponding to period

.

SQLsqlperiodinlist

sql='select PPMONTH, REGION, WEARSEG, sum(uncal_value) as uncal_value \
           from Ftable where region in ("Shanghai") and WEARSEG in ("Men","Women")\
           and PPMONTH in ({}) group by PPMONTH,WEARSEG'.format(','.join(['%s' for _ in period]))
cursor.execute(sql, period)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3175c-2bdac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3175c-2bdac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?