Thanks for your input!

1. We're using a clustered database (CockroachDB, for those who care)
that uses optimistic concurrency, so automatic transaction retries are
a must, and we need control over how those retries are done.

Interesting, we don't use that, but then again we've recently started using more funky stuff on the database side (TimescaleDB) so maybe one day...
 
2. We are using the same models for a couple of different projects (the
API itself and a script that is synchronizing between the old database
and the new), and not all the projects are built on Flask.  Initially,
I was able to get the sync script working with Flask-SQLAlchemy, but
things got ugly quickly when I started doing multithreading, so I
abandoned it and am now using Flask and SQLAlchemy separately.

When I thought about that use case, I supposed it would be OK to instantiate the app and start the app context from within the script, as it would also give you access to Flask's config file. But I did not think about multithreading. Would you recommend against creating the app instance and the app context in a command-line script?

Is the code you wrote to integrate Flask and SQLAlchemy opensource, and available somewhere?

Thanks again!

Aurélien