I am trying to insert pandas dataframe data into mysql database using sqlalchemy .The table table_test
has one column AUTO_INCREMENT. I want to get the value of the AUTO_INCREMENT column and use it in the later part of the program.
Below is my code :
from sqlalchemy import create_engine
mysqldb = create_engine("mysql://test:password@localhost/test")
df.to_sql(con=mysqldb, name='table_test',index=False, if_exists='append')
print (mysqldb.insert_id())
However the last print line giving me error .
File "test.py", line 208, in StagingCountLesserThanTarget
mysqldb.insert_id() AttributeError: 'Engine' object has no attribute 'insert_id'
how to get the last inserted id in mysql using sqlalchemy?