I am loading data from one table into pandas and then inserting that data into new table. However, instead of normal string value I am seeing bytearray.
bytearray(b'TM16B0I8') it should be TM16B0I8
What am I doing wrong here?
My code:
engine_str = 'mysql+mysqlconnector://user:pass@localhost/db'
engine = sqlalchemy.create_engine(engine_str, echo=False, encoding='utf-8')
connection = engine.connect()
th_df = pd.read_sql('select ticket_id, history_date', con=connection)
for row in th_df.to_dict(orient="records"):
var_ticket_id = row['ticket_id']
var_history_date = row['history_date']
query = 'INSERT INTO new_table(ticket_id, history_date)....'
th_df['ticket_id'], instead of giving me a string'TM16A0JY'it is giving me this array[77, 83, 90, 45, 48, 50, 53, 52, 57, 56]and after the insert when I looked into DB it is showing mebytearray(b'TM16A0JY'). Interestingly for integer IDs it is not showing bytearray and also inserting a integer value in db.4567.