-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (27 loc) · 944 Bytes
/
main.py
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
from config import logger, settings
from scraper import Engine
from transformer import Agent
from utils import create_inserter_objects
def main():
logger.info("Initializing Scraper Engine")
engine = Engine(
url=settings.URL,
max_retries=settings.REQUEST_MAX_RETRIES,
backoff_factor=settings.REQUEST_BACKOFF_FACTOR,
)
df = engine.fetch()
logger.info("Transforming Data")
df_transformed = Agent(df).transform()
logger.info("Preparing Database Inserter")
inserter = create_inserter_objects(
server=settings.MSSQL_SERVER,
database=settings.MSSQL_DATABASE,
username=settings.MSSQL_USERNAME,
password=settings.MSSQL_PASSWORD,
)
logger.info(f"Inserting Data into {settings.OUTPUT_TABLE}")
inserter.insert(df_transformed, settings.OUTPUT_TABLE)
logger.info("Application completed successfully")
return
if __name__ == "__main__":
main()