Answer the question
In order to leave comments, you need to log in
How to solve output problem in sqlite3?
The code:
import sqlite3
import datetime
with sqlite3.connect('test_db', detect_types = sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES) as con:
cur = con.cursor()
try:
data = cur.execute('SELECT * FROM vip_users').fetchall()
print(data)
except sqlite3.OperationalError:
print('ERROR')
File "/home/lastwek/Desktop/bot/test.py", line 7, in
data = cur.execute('SELECT * FROM vip_users').fetchall()
File "/usr/lib/python3.8/sqlite3 /dbapi2.py", line 64, in convert_date
return datetime.date(*map(int, val.split(b"-")))
ValueError: invalid literal for int() with base 10: b'23 13:28 :32.725766'
Answer the question
In order to leave comments, you need to log in
It looks like the field in the table was created as a DATE, not a TIMESTAMP, so it tries to convert to a DATE without a time when it's uploaded.
You can either use the correct field type initially, or explicitly specify the type in the request
select time_to_next_pay as "time_to_next_pay [timestamp]" from vip_users
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question