aboutsummaryrefslogtreecommitdiffstats
path: root/examples/sql/relationaltablemodel/connection.py
blob: 6bfc828c8dfede058bb4ad30d85293088589ec21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

"""PySide6 port of the relationaltablemodel example from Qt v6.x"""


from PySide6.QtSql import QSqlDatabase


def createConnection():

    def check(func, *args):
        if not func(*args):
            raise ValueError(func.__self__.lastError())
    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(":memory:")

    check(db.open)