File size: 1,133 Bytes
99f834c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """Database connectors and schema mapper."""
from core.database.base import (
ConnectionConfig,
DatabaseConnector,
FieldMapping,
SchemaMapper,
SEQUENCE_FIELDS,
)
from core.database.sqlite import SQLiteConnector
from core.database.postgres import PostgreSQLConnector
from core.database.csv_importer import CSVConnector
def create_connector(config: ConnectionConfig) -> DatabaseConnector:
"""Factory: return the appropriate connector for config.backend."""
backends = {
"sqlite": SQLiteConnector,
"postgres": PostgreSQLConnector,
"postgresql": PostgreSQLConnector,
"csv": CSVConnector,
"excel": CSVConnector,
}
cls = backends.get(config.backend.lower())
if cls is None:
raise ValueError(
f"Unknown backend '{config.backend}'. "
f"Supported: {list(backends.keys())}"
)
return cls(config)
__all__ = [
"ConnectionConfig",
"DatabaseConnector",
"FieldMapping",
"SchemaMapper",
"SEQUENCE_FIELDS",
"SQLiteConnector",
"PostgreSQLConnector",
"CSVConnector",
"create_connector",
]
|