Skip to content

Commit

Permalink
FEAT: Add sample XYZ Auto BI rate index to sample database.
Browse files Browse the repository at this point in the history
  • Loading branch information
genedan committed Jan 14, 2025
1 parent 48d49f5 commit f07efb0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions faslr/samples/db/generate_sample_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from faslr.schema import (
CountryTable,
IndexTable,
IndexValuesTable,
LocationTable,
StateTable,
LOBTable,
Expand All @@ -24,6 +26,10 @@
ProjectViewData
)

from faslr.utilities.sample import (
XYZ_RATE_INDEX
)

from sqlalchemy.orm import sessionmaker
from uuid import uuid4

Expand Down Expand Up @@ -125,6 +131,26 @@

session.add_all(obj_list)

new_index = IndexTable(
description=XYZ_RATE_INDEX['Name'][0],
scope='Global'
)

session.add(new_index)
session.flush()

df_rate_changes = pd.DataFrame(data={'year': XYZ_RATE_INDEX['Origin'], 'change': XYZ_RATE_INDEX['Change']})
df_rate_changes['index_id'] = new_index.index_id

rate_change_list = df_rate_changes.to_dict('records')

obj_list = []
for record in rate_change_list:
data_obj = IndexValuesTable(**record)
obj_list.append(data_obj)

session.add_all(obj_list)

session.commit()


Expand Down

0 comments on commit f07efb0

Please sign in to comment.