【问题标题】:Sqlite and python between not returning valueSqlite和python之间不返回值
【发布时间】:2020-08-20 12:48:15
【问题描述】:

我正在尝试在我的数据库上实现选择,但每次将 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() 代码工作并且我得到了值时,我没有看到问题。

【问题讨论】:

    标签: python sql python-3.x sqlite


    【解决方案1】:

    您必须验证datetime.now() 的格式是否与您的数据库格式匹配。你的数据库是什么格式的,因为Sqlite没有具体的日期时间格式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 2014-09-27
      • 1970-01-01
      相关资源
      最近更新 更多