gpt4 book ai didi

sql - 格式pandas.Timestamp用于SQLite查询

转载 作者:行者123 更新时间:2023-12-03 18:29:46 25 4
gpt4 key购买 nike

from pandas.io import sql
import sqlalchemy

eng = sqlalchemy.create_engine('sqlite:////path/to/file.db')

In [20]: sql.execute("select * from mytable", eng).fetchone()
Out[20]: (0, u'2013-03-13 13:05:00.000000', 1, 0, 0, 0)


现在我该怎么做才能使它起作用:

target = Timestamp('2014-04-30')
sql.execute("select * from mytable where date = ?", eng, params=target).\
fetchone()

最佳答案

str_format = '%Y-%m-%d %H:%M:%s'
target = Timestamp('2014-04-30').strftime(str_format)

关于sql - 格式pandas.Timestamp用于SQLite查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23556882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com