It sounds like you're encountering a few issues related to connecting to the database when deploying your application to Google App Engine. Given the information you've provided, I can suggest a more structured approach to resolve the issue. Let's break it down:
Key Areas to Address: SQLAlchemy Database URI: The database connection string you're currently using (SQLALCHEMY_DATABASE_URI) works fine for local development, but when deploying to Google Cloud SQL, you should switch to using a Unix socket connection instead of connecting via a public IP. To know more click this link