PyQt5: specifying QSqlTableModel

Rich Shepard rshepard at appl-ecosys.com
Fri Jun 4 20:38:17 BST 2021


On Fri, 4 Jun 2021, Colin McPhail wrote:

> It might be an idea to add some error checking. I put the following just
> after the self.model.select() line:
>
>        model_error = self.model.lastError()
>        if model_error.isValid(): # i.e. there is an error
>            logging.debug(f"model error: {model_error.text()}")
>        else:
>            logging.debug("no model error")

> Perhaps you might see some other message that indicates what's going wrong?

Colin,

Indeed I do. The last few lines of the log file for your modified file shows
the problem:
INFO:root:found database
DEBUG:root:Defining model/view
DEBUG:root:model error:  Unable to find table foods_episodes
DEBUG:root:End of Program

Yet when I open foods.db with sqlite-3.34.0 the table is present.

Similarly, when I run my activitytypes.py I get the same error:
INFO:root:found database
DEBUG:root:Defining model/view
DEBUG:root:model error:  Unable to find table activitytypes
DEBUG:root:End of Program

And that table is present in the bustrac database.

Please suggest how i trace this inability to find database tables to its
source.

Thanks again,

Rich


More information about the PyQt mailing list