31 lines
936 B
Python
31 lines
936 B
Python
import yaml
|
|
import os
|
|
from .connector import SQLConnector
|
|
from .modeler import SQLModeler
|
|
from .loader import SQLLoader
|
|
from .config import config as cfg
|
|
import pandas as pd
|
|
|
|
|
|
def get_source_type(cnt_name, action="extract_from"):
|
|
with open(os.path.expanduser("~")+"/.dft/sources.yml",'r') as file:
|
|
data = yaml.safe_load(file)
|
|
target = data[cfg["profile"]]['target']
|
|
return data[cfg["profile"]][target][action][cnt_name]["type"]
|
|
|
|
def get_source(src_name, filepath, action="extract_from"):
|
|
src_type = get_source_type(src_name, action)
|
|
#TODO: SelectConnector depending on other type
|
|
if src_type == "sql":
|
|
# SQLSource
|
|
return SQLSource(src_name, filepath)
|
|
else:
|
|
return "Source type not supported for now."
|
|
|
|
|
|
class SQLSource(SQLModeler, SQLConnector, SQLLoader):
|
|
type = "sql"
|
|
|
|
def __init__(self, src_name, filepath) -> None:
|
|
super().__init__(src_name, filepath)
|