can a return value of a function be passed in the where clause
Question: I have a python code that displays a list of station ID and air temperature
for certain number of days. In the code below I have passed the dates as a
list. But that is cumbersome coding since I have to write all the dates in the
list. Is there any way wherein I can pass the return value of a function to
the where clause. I want to know how a range of values with start and end date
can be passed in the query below. Following is the code snippet:

    
    
    import MySQLdb
    import os,sys
    import datetime
    path="C:/Python27/"
    conn = MySQLdb.connect (host = "localhost",user = "root", passwd = "CIMIS",db = "cimis")
    c = conn.cursor()
    message = """select stationId,Date,airTemperature from cimishourly where stationId in (2,7) and Date in ('2016,01,01','2016,01,04') """
    c.execute(message,)
    result=c.fetchall()
    for row in result:
        print(row)
    conn.commit()
    c.close()
    


Answer: Yes you can substitute the return value of a function in your query. Because
`message` is just a string you can concatenate it like you would any other
string.

`message = """select stationId,Date,airTemperature from cimishourly where
stationId in (2,7) and Date in (""" + functionToGetDates() + """)"""`

The parentheses can be formatted in the function or in the original string
like I chose to do.

