jkklee/pymysql-pool

How do i connect to my Mysql server using SSHClient.

Chintan-collab opened this issue · 3 comments

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

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

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

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.