jkklee / pymysql-pool

A simple but robust connection pool (with multiplexing) base on PyMySQL, mainly used for multi threads mode, which also compatible with single thread mode.
GNU General Public License v3.0
177 stars 49 forks source link

How do i connect to my Mysql server using SSHClient. #24

Closed Chintan-collab closed 4 weeks ago

Chintan-collab commented 11 months ago

This is my code for the same.

Code: ssh_client = paramiko.SSHClient() ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_client.connect(**gb.ssh_config, look_for_keys=False) ssh_channel = ssh_client.get_transport().open_channel( 'direct-tcpip', ('127.0.0.1', gb.dev_db_config["port"]), (gb.dev_db_config["host"], gb.dev_db_config["port"]), ) mysql_connection = pymysqlpool.ConnectionPool( host='x.x.x.x', port=3306, user="admin", password="Admin@123", database='ai_netra' )

Help me with this.

jkklee commented 11 months ago

I think paramiko is working with ssh protocol, not work with mysql protocol, so I don't quite understand what you mean.

Chintan-collab commented 11 months ago

Actually, the problem is I am trying to establish a connection to my mysql db hosted on EC-2 from my local system using python. If i simply try to connect using pymysql then it does function as expected but during operation and commit it gets disconnected due packet sequencing error. So, I am try to create a pool of connections to get pass this error.

jkklee commented 11 months ago

I think you use the multi-threading, that's why you consider to use pymysql-pool. That's right, it will help you. pymysql-pool is s fully compatible with pymysql,so if you need some outer wrap, you just need to find how it deal with pymysql.