Trying to understand UnmappedInstanceError using SQLAlchemy
I am trying to populate a table in SQL with data in the dataframe below. The code functions as expected when I use other data frames with exactly the same columns and data types, but only for this data block only, the error is sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.list' is not mapped
obtained from the string session.add([yc_node_hist(fk_yc_update = listofindices3[i],curve_date = row1['Date'], tenor = row1['Year'], Abrv = row1['VALUE'])])
. I am using automap()
to map a table yc_node_hist
to a class. My main problem is that I cannot figure out what exactly "Error" means .
Date Year VALUE ABBRV
0 2005-01-04 0.08333333 4.709456 GBP
1 2005-01-05 0.08333333 4.713099 GBP
2 2005-01-06 0.08333333 4.707237 GBP
3 2005-01-07 0.08333333 4.705043 GBP
yc_node_hist
:
create table yc_node_hist
(
id bigint IDENTITY(1,1) PRIMARY KEY,
fk_yc_update bigint NOT NULL FOREIGN KEY REFERENCES yc_update(id),
curve_date date NOT NULL,
tenor float NOT NULL,
Abrv float NOT NULL
)
The code I'm using:
engine2 = YieldData.Connectionengine()
session = Session(bind=engine, expire_on_commit=False)
for (i1, row1), (i2, row2) in pairwise(df.iterrows()):
if row1['ABBRV'] == row2['ABBRV'] and isinstance(row1['VALUE'], float)==1:
print(row1)
session.add([yc_node_hist(fk_yc_update = listofindices3[i],curve_date = row1['Date'], tenor = row1['Year'], Abrv = row1['VALUE'])])
source to share
No one has answered this question yet
Check out similar questions: