Guest User

Untitled

a guest
Oct 20th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import MySQLdb
  2. import sshtunnel
  3.  
  4. with sshtunnel.SSHTunnelForwarder(
  5. ("remote_ip", 22),
  6. ssh_username="centos",
  7. ssh_pkey="~/.ssh/id_rsa",
  8. remote_bind_address=("mysql_host", 3306),
  9. ) as tunnel:
  10. connection = MySQLdb.connect(
  11. user="mysql_user",
  12. password="mysql_password",
  13. host="127.0.0.1",
  14. database="database_name",
  15. port=tunnel.local_bind_port)
Add Comment
Please, Sign In to add comment