2 回答

TA貢獻1842條經(jīng)驗 獲得超22個贊
要獲得要推薦的輸入的日期,您可以格式化您的字符串
date = input("DATE:YYYY-MM-DD")
query = '''
SELECT timestamp , something , someotherthing
FROM database
WHERE timestamp = {date}
'''
pd.read_sql_query(query.format(date=date),con)
或沒有日期參數(shù)
date = input("DATE:YYYY-MM-DD")
query = '''
SELECT timestamp , something , someotherthing
FROM database
WHERE timestamp = {}
'''
pd.read_sql_query(query.format(date),con)

TA貢獻1816條經(jīng)驗 獲得超6個贊
連接字符串。
date = input("DATE:YYYY-MM-DD")
query = "SELECT timestamp , something , someotherthing \
FROM database \
WHERE timestamp = " + str(date)
pd.read_sql_query(query,con)
添加回答
舉報