Tuesday, 21 May 2019

Create Engine(SQLalchemy) for GCP database in a python script

I want my python script to read data from GCP database but I don't know how to make a connection.

Generally when we connect to local Database we do something like this:

from sqlalchemy import create_engine
engine = create_engine('postgresql://postgres:password@localhost:5432/django_app')    
data = pd.read_sql_query('select * from "ABC"', con=engine)

basic layout to connect to a local database:

dialect+driver://username:password@host:port/database

but how can I do the same with the database residing on GCP. Do I need to pass my instance name instead of localhost ?



from Create Engine(SQLalchemy) for GCP database in a python script

No comments:

Post a Comment