Python 3.3 + QtSql + ssh tunnel - Connection problem

D

D. Xenakis

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Python 3 and SSH Tunnel 10

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top