Open alexanderankin opened 6 months ago
From #445
from abc import ABC, abstractmethod
class DBContainer(ABC):
@abstractmethod
def get_connection_url(self, *, **kwargs): # psycopg v3 cannot handle sqla style URLs, so it needs a driver=None :-(
"""Get a DB connection URL which can be used to connect to the DB."""
def _create_connection_url( ... as now ...):
"""Helper to create a DB API connection URL."""
I'm not sure if this is worth a extra class in the hierarchy, especially because it's unclear to me if that URL can be useful for all DB container or only the ones which are based on the python DB API (=RDBMS ones, not stuff like mongodb or redis): I've no clue if they also can be connected to with a single URL (kafka can not, I think).
Given that each container would need to implement the method anyway, one could also make _create_connection_url()
a pure function and let each container just declare the method themselves...
from https://github.com/testcontainers/testcontainers-python/pull/445#issuecomment-1985436334