0
我想将从sqlite3数据库中选择的日期时间转换为unixepoch。我猜想,简单的方法是在unixepoch中的数据库中插入时间戳,但我宁愿不要,因为这会使我的数据库不易读。将sqlite3时间戳转换为python中的纪元时间
conn = sqlite3.connect('test.db')
c = conn.cursor()
c.execute('CREATE TABLE if not exists table_name (datetime text, column1 real, column2 real)')
cur.execute("INSERT INTO table_name VALUES (datetime(CURRENT_TIMESTAMP, 'localtime'),?,?)", data)
c.execute("SELECT datetime from table_name")
#here I would like to convert the above selection (datetime in localtime) to unixepoch
感谢您阅读本文!