Inserting data into multiple columns in MySQL table from python -


For some reason, I'm unable to insert data into multiple columns in mysql table. As soon as I put it in the first column (any column), I find it difficult to include in other columns. I saw that after putting it in the first column, in the second column, the entry begins from the point where the first column was finished, but on the other. I tried to put it on a third column but there was no integration.

See my code below:

  week1 = xrange (1,101,1) #for column1 week2 = xrange (1,101,1) # for column 2 Exemptemany ("Entrance to Enhancement (Class ID) Value (% s)", [(X, for X for Week) db.commit ()  

for your suggestions thank you in advanced.

You have to create lists with two columns; If your two columns are coming from two different Iterables, then connect to them using zip () :

  week1 = xrange (1, 101) ) # Column1 week2 = for xrange (1, 101) # for column 2. Executionemany ("Enter Promotion (Class ID, Other Columns) Price (% s,% s)", ZIP (Week 1, Week 2) db.commit ()  

< Code> zip (week 1, week 2) prepares a sequence of tuples; A pair of values ​​taken from both input sequences: [(week 1 [0], week 2 [0]), (week 1 [1], week 2 [1]), ...] .


Comments