I'm working with Data-frames in Python and trying to insert data in MySQL Database. I know I can use df.to_sql
to insert dataframe into sql but in my case, I've a list in one of the cells of dataframe and I've to insert that list into multiple columns of table in database.
Here is my dataframe:
UserId UserName Address Res
1 User1 Add1 [1,2,3...36]
2 User2 Add2 [1,2,3...36]
This is my database table structure:
UserId UserName Address Res1 Res2 Res3... Res36
Now I'm stuck here that how can I insert Res
data into multiple columns in an efficient way? List data is in sequence with column names so I don't have to worry about correct col name/ data.
Any guesses??