Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52300

Python 3.3 + QtSql + ssh tunnel - Connection problem

Newsgroups comp.lang.python
Date 2013-08-10 04:32 -0700
Message-ID <60c57e73-9aa2-4eb7-896a-b1d7ea99c610@googlegroups.com> (permalink)
Subject Python 3.3 + QtSql + ssh tunnel - Connection problem
From "D. Xenakis" <gouzounakis@hotmail.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Python 3.3 + QtSql + ssh tunnel - Connection problem "D. Xenakis" <gouzounakis@hotmail.com> - 2013-08-10 04:32 -0700

csiph-web