Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29539

Connecting AWS RDS from sqlalchemy via EC2

$
0
0

I am trying to connect to AWS RDS (postgres) from EC2 machine with the following code. This works perfectly when I run it from my local machine and creates the table in the database. But when I run it from EC2 it throws an error:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection timed out Is the server running on host "" (IP) and accepting TCP/IP connections on port ?

import csv
import boto3

from io import StringIO
from sqlalchemy import create_engine, MetaData, Table, Column, BigInteger, Date,  Integer, String
engine = create_engine('postgresql://<user>:<password>@<host>:<port>/<db>')

table_name = 'checking'
meta = MetaData()

table_name = Table(
   table_name, meta,
   Column('phone', BigInteger, primary_key = True),
   Column('first_name', String),
   schema = 'testing'
)

meta.create_all(engine)

I believe there is some permission issue with RDS or EC2. On EC2 i have anywhere access to HTTP, HTTPS, TCP, SSH.


Viewing all articles
Browse latest Browse all 29539

Trending Articles