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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do i connect to my Mysql server using SSHClient.

Chintan-collab opened this issue · 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.

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.

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.