Python 3.3 + QtSql + ssh tunnel - Connection problem

D. Xenakis gouzounakis at hotmail.com
Sat Aug 10 07:32:42 EDT 2013


Im using python 3.3 on win7 64bit and trying to connect to a MySQL database on a remote server through a putty ssh tunnel.

Running the script below im getting "Physical connection to the database did not activate!". What im i doing wrong?! I tried to find a working example but couldnt find one. thx in advance guys

from PyQt5 import QtSql

def main():
    db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
    db.setHostName("127.0.0.1")
    db.setPort(3306)
    db.setDatabaseName("username_databasename")
    db.setUserName(username)
    db.setPassword(userpassword)
    ok = db.open()

    if ok:
        print ("Physical connection to the database activated")
    else:
        print ("Physical connection to the database did not activate!")
        return
    create_table(db)
    db.close()

main()



More information about the Python-list mailing list