Add error message when query failed to prepare

This commit is contained in:
Florian Bruhin 2017-06-20 12:03:31 +02:00
parent 29ce1b3811
commit c1776bbf9d

View File

@ -70,7 +70,8 @@ class Query(QSqlQuery):
super().__init__(QSqlDatabase.database())
log.sql.debug('Preparing SQL query: "{}"'.format(querystr))
if not self.prepare(querystr):
raise SqlException('Failed to prepare query "{}"'.format(querystr))
raise SqlException('Failed to prepare query "{}": "{}"'.format(
querystr, self.lastError().text()))
self.setForwardOnly(forward_only)
def __iter__(self):