[PyQt] How to close QSqlDatabase connection?
Hans-Peter Jansen
hpj at urpla.net
Mon Nov 12 19:55:20 GMT 2007
Am Montag, 12. November 2007 schrieb Sibylle Koczian:
>
> So I looked around and saw that I had this:
>
> def main(args):
> app = QtGui.QApplication(args)
> if not visa_conn():
> sys.exit(1)
> visa_mf = VisaMF()
> visa_mf.show()
> sys.exit(app.exec_())
>
> if __name__ == '__main__':
> main(sys.argv[1:])
>
> while "cachedtable.py" has no separate main function and calls the app
> constructor with the full list sys.argv. Doing the same in my own example
> seems to do the trick. But why?
I will (hopefully) leave a more satisfying answer to the experts, but
omitting sys.argv[0] doesn't make any sense to me anyway. Maybe the process
name is used internally for creating the default connection name, and
creates a None, NULL, whatever mismatch on close later in this case.
You may want to experiment a bit with faked sys.argv args, e.g.: [], [''],
['xxx'], and let us know about the outcome. Using a different database
backend would also be interesting.
Pete
More information about the PyQt
mailing list