Python Forum

Full Version: SSH port forwarding and connection to SQL Server in separate threads freezes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
(Nov-25-2019, 09:02 PM)Denni Wrote: [ -> ]Okay but I first wanted to take this one bite at time and make sure we are on the same page as we move forward -- if what I provided creates a solid usable connection to an sqlite3 database on your end -- and then you can use this class to connect to your database (since I cannot duplicate that specific aspect) -- then we will have that base stuff in place -- and then can move to the next piece
Using the code you have provided I opened the connection to SQL Server database and was able to retrieve data from a table. Of course I have made some small modification (uncommenting import of SQLAlchemy and duplicating CheckConnection method so it fits SQL Server environment).

Nevertheless the connection has been established but one again I must underline that in order to do it I have created a SSH Tunnel using PuTTY and then forward the SQL Server port so the connection is to localhost:1433.
Okay so can you post your MUC so I can examine it -- or is the PuTTY stuff external to your code base?
(Nov-27-2019, 04:23 PM)Denni Wrote: [ -> ]Okay so can you post your MUC so I can examine it -- or is the PuTTY stuff external to your code base?

PuTTY is external stuff. Using your code and mine to establish ssh connection and port forwarding and then establishing connection fails. As I said in my very first post. When I am trying to establish the connection to SQL Server with SSH connection and port forwarding running in separate thread the GUI freezes.
okay so how are you implementing
1) The PuTTY connection (which establishes the SSH connection to the database?)
2) The communication from the program to the database via the PuTTY connection

Also have you tested this as a standalone process without a Thread -- aka you run the program it talks to the database through PuTTY and gets a reply? Nothing complicated and no GUI just straight python

Again just trying to make sure we are on the same page and just crossing my I's and dotting my T's
(Dec-02-2019, 06:51 PM)Denni Wrote: [ -> ]okay so how are you implementing
1) The PuTTY connection (which establishes the SSH connection to the database?)
2) The communication from the program to the database via the PuTTY connection
The connection via PuTTY established port forwarding over SSH so the in order to talk to SQL Server I need to establish connection to localhost at 1433 port (PuTTY is forwarding remote port on which SQL Server listens to localhost)

(Dec-02-2019, 06:51 PM)Denni Wrote: [ -> ]Also have you tested this as a standalone process without a Thread -- aka you run the program it talks to the database through PuTTY and gets a reply? Nothing complicated and no GUI just straight python
Yes I did and it works without problem. The only thing I have not tried is to establish port forwarding over SSH and then connection to SQL Server without GUI. However I guess it should also use threading.
(Dec-03-2019, 01:17 PM)jan_pips Wrote: [ -> ]Yes I did and it works without problem. The only thing I have not tried is to establish port forwarding over SSH and then connection to SQL Server without GUI. However I guess it should also use threading.

Okay I would suggest testing this without Threading and see if it works without a hitch then share the MUC (Minimal Usable Code) you used along with the MUC version of how you plan to implement the QThread as I think you are implementing the QThread incorrectly which is no fault of your own because Qt's Documentation is currently wrong on that as it is still showing PyQt4 way versus PyQt5 way
Pages: 1 2 3