title: How to connect to AWS RDS MySql database with Python
body: <p>I am currently trying to connect to my MySql database created on AWS with a python program using the library PyMySQL</p>
  <pre><code># !/usr/bin/env python
  # -*- coding: utf-8 -*-
  import pymysql
  
  host = 'admin.cjp8hsqu4je0.us-east-2.rds.amazonaws.com'
  user = 'admin'
  password = '12345678'
  database = 'admin'
  
  connection = pymysql.connect(host, user, password, database)
  with connection:
      cur = connection.cursor()
      cur.execute(&quot;SELECT VERSION()&quot;)
      version = cur.fetchone()
      print(&quot;Database version: {} &quot;.format(version[0]))
  
  </code></pre>
  <p>When I run the above code I get the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymysql\connections.py&quot;, line 581, in connect
      sock = socket.create_connection(
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\socket.py&quot;, line 808, in create_connection
      raise err
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\socket.py&quot;, line 796, in create_connection
      sock.connect(sa)
  socket.timeout: timed out
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;bot.py&quot;, line 10, in &lt;module&gt;
      connection = pymysql.connect(host, user, password, database)
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymysql\__init__.py&quot;, line 94, in Connect
      return Connection(*args, **kwargs)
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymysql\connections.py&quot;, line 325, in __init__
      self.connect()
    File &quot;C:\Users\SuperPC\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pymysql\connections.py&quot;, line 630, in connect
      raise exc
  pymysql.err.OperationalError: (2003, &quot;Can't connect to MySQL server on 'admin.cjp8hsqu4je0.us-east-2.rds.amazonaws.com' (timed out)&quot;)
  </code></pre>
  <p>What am I doing wrong? The arguments I gave to the function are correct. Could it be a problem with the MySql driver?</p>