[PyQt] How to store date in Sqlite and view it in column in QTableView?

Sibylle Koczian nulla.epistola at web.de
Sun Jun 17 10:41:01 BST 2018


Am 15.06.2018 um 15:06 schrieb nenad:
> With PostgreSQL everything is ok.
> 
> But I have a problem how to store date in Sqlite and view it in column in
> QTableView (with Sqlite database as a model for QTableView). Adding new rows
> with date type seems like it adds some other type, not date. And date column
> sort in QTableView doesn't work as it is supposed to.
> 

Sqlite hasn't got a "date type" like PostgreSQL and others. I suspect 
it's that fact that's causing you problems. Documentation:

https://sqlite.org/datatype3.html

especially 2.2 and

https://sqlite.org/lang_datefunc.html

If you define your date column as "text" in the database and store your 
date values in ISO format they should "just work" in the QTableView, 
including sorting.

HTH
Sibylle






More information about the PyQt mailing list