sqlalchemy.exc.ProgrammingError: (snowflake.connector.errors.ProgrammingError) 390114 (08001):

Viewed 351

Created a Flask app that uses Flask SQLAlchemy to insert records into a Snowflake table. It works great locally, in staging, and production, but it occasionally gives me the following error:

sqlalchemy.exc.ProgrammingError: (snowflake.connector.errors.ProgrammingError) 390114 (08001): Authentication token has expired. The user must authenticate again.

I spoke to one of our DBA's and was told to add client_session_keep_alive=True to the end of my URI. I have tried this and it still gives me the token expired error.

Has anyone had any luck getting this to work.

2 Answers

Try using Snowflake integration object:

create or replace api integration demonstration_external_api_integration_01
api_provider=aws_api_gateway
api_aws_role_arn='arn:aws:iam::123456789012:role/my_cloud_account_role'
api_allowed_prefixes=('https://xyz.execute-api.us-west-2.amazonaws.com/production')
enabled=true;

adding connection.close() and engine.dispose() worked for me. Has been around 12 hours and hasn't given me the token expired error.

Related