I want to work with data in Pandas, so I use the pandas method read_sql I want to get it from Amazon RDS (PostgreSQL).
Insert sqlalchemy, padas
pip install -U sqlalchemy pandas
import sqlalchemy
import pandas
## DB Connection configuration
username = "USERNAME"
password = "PASSWORD"
endpoint = "ENDPOINT" # something like amazonaws.com:5432
dbname = "DBNAME"
## Connect to Db
con = sqlalchemy.create_engine("postgresql://%s:%s@%s/%s" % (username, password, endpoint, dbname))
## Get Data
data = pandas.read_sql("YOUR_SQL", con)
print(data)
Recommended Posts