The Problem

You're building a system that supports multiple databases — MySQL, PostgreSQL, MongoDB. Different services in your application need to create database-specific objects — queries, transactions, updators.

The naive approach? Let each service decide which object to create:

from abc import ABC, abstractmethod

class Database(ABC):