Managing Database Connections
SQLAlchemy provides a standard interaction pattern for creating engines, metadata, tables, and mappers. However, in the context of a Plone application, we have some particular requirements:
- Different products may want to manage their own database connections, meaning that we need to be able to manage multiple Engines simultaneously.
- Zope is a multi-threaded server. We need to ensure that any shared database resources are thread-safe.
- Database transactions need to be synchronized with Zope transactions. If one fails and rolls back, so should the other.
- Data source names (DSNs) may not be known until run time, for example if they are stored in the ZODB and exposed as configuration settings to the site administrator.