python - Sqlite和python之间不返回值
问题描述
我正在尝试在我的数据库上实现选择,但每次将 datetime.now() 作为 arg 时,它都不会返回列表。
Sqlite3 命令:
if from_date is not None and to_date is not None:
ping_select = """
select valor
from dispatcher_storage
where timestamp between ? and ? and chave = ?
"""
self.data_base_conn.execute(ping_select, (from_date, to_date, key))
sql_time_history = self.data_base_conn.fetchall()
self.sqliteConnection.commit()
其他模块中的代码部分是:
ping_histogram = Dispatcher().fetch_all("provider_ping", date_past, datetime.now())
但是,当我None
代替datetime.now()
代码工作并获得值时,我没有看到问题。
解决方案
您必须验证格式是否datetime.now()
与您的数据库格式匹配。您的数据库的格式是什么,因为 Sqlite 没有特定的日期时间格式。
推荐阅读
- sql - SQL - 多行合二为一
- javascript - 如何在确认窗口之前调用验证功能?
- installation - 在 Ubuntu 16.04 上为 mecab Japanese tokenizer 安装 ipadic
- javascript - Angular 5 传输状态 api
- artifactory - jfrog rt 搜索中的 Artifactory AQL:包含字段
- javascript - 如果使用 jQuery.ajax 或 XMLHttpRequest 发出请求,Service Worker 获取处理程序不会触发
- php - 查找并删除紧随其后的 MySQL 行重复
- go - 在从 VCS 结帐期间,GoLand IDE 不会将项目放入工作区
- php - 从数组中返回对象项
- spring-webflux - 将自定义响应标头添加到 Spring WebFlux 控制器端点