from orm import engine
from sqlalchemy import text
import pandas as pd
import networkx as nx
import json
import matplotlib.pyplot as plt

# prep data
Firm = pd.read_csv("Firm_amended.csv")
Firm['Code'] = Firm['Code'].astype('string')
Firm.fillna(0, inplace=True)
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)

with open('SQL_analysis_risk.sql', 'r') as f:
    str_sql = f.read()
str_sql = str_sql.replace('iiabmdb', 'iiabmdb20260127')
with engine.connect() as conn:
    result = pd.read_sql(sql=text(str_sql), con=conn)
print(result)