I assume that you will need port forwarding. I recommend sshtunnel.SSHTunnelForwarder
import mysql.connector import sshtunnel with sshtunnel.SSHTunnelForwarder( (_host, _ssh_port), ssh_username=_username, ssh_password=_password, remote_bind_address=(_remote_bind_address, _remote_mysql_port), local_bind_address=(_local_bind_address, _local_mysql_port) ) as tunnel: connection = mysql.connector.connect( user=_db_user, password=_db_password, host=_local_bind_address, database=_db_name, port=_local_mysql_port) ...
Carlos D.
source share