diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py index c051acf03..e0b55dbd2 100644 --- a/qutebrowser/misc/sql.py +++ b/qutebrowser/misc/sql.py @@ -41,6 +41,13 @@ def close(): QSqlDatabase.removeDatabase(QSqlDatabase.database().connectionName()) +def version(): + """Return the sqlite version string.""" + result = run_query("select sqlite_version()") + result.next() + return result.record().value(0) + + def run_query(querystr, values=None): """Run the given SQL query string on the database. diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 08779e097..ac74f997a 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -45,7 +45,7 @@ except ImportError: # pragma: no cover import qutebrowser from qutebrowser.utils import log, utils, standarddir, usertypes, qtutils -from qutebrowser.misc import objects, earlyinit +from qutebrowser.misc import objects, earlyinit, sql from qutebrowser.browser import pdfjs @@ -327,6 +327,10 @@ def version(): lines += ['pdf.js: {}'.format(_pdfjs_version())] + sql.init() + lines += ['sqlite: {}'.format(sql.version())] + sql.close() + lines += [ 'SSL: {}'.format(QSslSocket.sslLibraryVersionString()), '', diff --git a/tests/unit/misc/test_sql.py b/tests/unit/misc/test_sql.py index 4a5299b48..b24f2fbcf 100644 --- a/tests/unit/misc/test_sql.py +++ b/tests/unit/misc/test_sql.py @@ -120,3 +120,6 @@ def test_delete_all(qtbot): with qtbot.waitSignal(table.changed): table.delete_all() assert list(table) == [] + +def test_version(): + assert isinstance(sql.version(), str) diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 54ee2cdd0..8c0f16081 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -834,6 +834,7 @@ def test_version_output(git_commit, frozen, style, with_webkit, 'QApplication': (stubs.FakeQApplication(style='STYLE') if style else stubs.FakeQApplication(instance=None)), 'QLibraryInfo.location': (lambda _loc: 'QT PATH'), + 'sql.version': lambda: 'SQLITE VERSION', } substitutions = { @@ -892,6 +893,7 @@ def test_version_output(git_commit, frozen, style, with_webkit, MODULE VERSION 1 MODULE VERSION 2 pdf.js: PDFJS VERSION + sqlite: SQLITE VERSION SSL: SSL VERSION {style} Platform: PLATFORM, ARCHITECTURE{linuxdist}