Hi all,
i’m using python google cloud sql connector into my Flask application, so i can read and write data from my istance of google cloud sql.
This is my code for connection:
def getconn():
with Connector() as connector:
conn = connector.connect(
instance_connection_name,
"pg8000",
user = db_user,
password = db_pass,
db = db_name,
ip_type = IPTypes.PUBLIC
)
return conn
and into my app.py file i set the connection in this way:
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
"creator" : getconn,
"max_overflow": 2,
"pool_timeout": 30,
"pool_size": 5,
"pool_recycle": 1800
}
db.init_app(app)
now i try to add some feature with this code:
@blp.route("/v0/service")
class IstanceRegister(MethodView):
@blp.arguments(JobSchema)
def post(self, istance_data):
search_list = ast.literal_eval(istance_data['search_list'])
uuid_istance = istance_data['unit_uid']
token = get_token()
job_created = manage_data(search_list,token)
for job in job_created:
if job['status'] == 'ok':
jj = jobModel(
client_uid_user = ['xxxxxxx'],
created_at = date_time,
status = 'active',
unit_uid = job['istance_uuid'],
country = ['USA']
)
db.session.add(jj)
db.session.commit()
print('Insert ok')
else:
print('Error insert')
return {"message": "Result creation"}, 201
Now when i run the app from my laptop and i call the api to insert data, i receive this errore connection
Cannot connect to host sqladmin.googleapis.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
The same code using into other app deployed as cloud run service works fine. How i can fix it when i run from my laptop?