简体   繁体   中英

Python Pandas read_sql - call previously specified date

I have a sql query and I want to specify the date outside of the where query so it can be changed as needed. The following code isn't working and I'm not sure what else to try.

startdate='2018-01-01'

test=pd.read_sql("""select * from database.table where date > :startdate ; """ , connection)

这个怎么样

test=pd.read_sql('select * from database.table where date > {}'.format(startdate) , connection)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM