[PyQt] Is it possible to subclass QSqlDatabase?

Mattia Borsalino mattia.borsalino at gmail.com
Fri Feb 6 03:39:17 GMT 2009


I'm trying to subclass QSqlDatabase, which appears to not be allowed.
The following code crashes at the first line of the main code
(addDatabase). What am I missing?

Thanks in advance,


# -*- coding: latin-1 -*-
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *

class MyDatabase(QSqlDatabase):
    subclasses QSqlDatabase
    def __init__(self, parent=None):
        super(MyDatabase, self).__init__(parent)

if __name__ == '__main__':
    db = MyDatabase().addDatabase("QMYSQL")
    db.open('root', 'mypassword')

More information about the PyQt mailing list