我无法连接到Google Cloud上的数据库。 在我的Dockerfile中,我正在调用python脚本以连接到数据库,如下所示:
....
ADD script.py /home/script.py
CMD ["/home/script.py"]
ENTRYPOINT ["python"]
import sqlalchemy as db
# x.x.x.x is the public ip of the database instance
engine = db.create_engine('postgresql+psycopg2://user:db_pass@x.x.x.x/db_name')
connection = engine.connect()
metadata = db.MetaData()
experiments = db.Table('experiments', metadata, autoload=True, autoload_with=engine)
但是我一直收到此错误:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Operation timed out
Is the server running on host "x.x.x.x" and accepting
TCP/IP connections on port 5432?
有人可以帮助我吗?谢谢!!