I am using sqlalchemy to upload the dataframe to the AWS RDS Mysql. Below is my code, I would like to display the warnings (Specially for data truncation) as well.
def load_data(translog,input_size):
try:
print("Creating connection")
engine = create_engine("mysql+mysqlconnector://<username>:<pwd>@XXXXXXX.rds.amazonaws.com/XXXX",
poolclass=NullPool)
with engine.connect() as connection:
translog.to_sql(con=connection,name='transtry',if_exists='append', index=False)
connection.close()
except Exception as e:
#except mysql.connector.Error as error:
print("Failed to insert record into Transaction table {}".format(e))
engine.dispose()
print("MySQL connection is closed")