Inserting values from python3 list into mysql

后端 未结 1 1912
借酒劲吻你
借酒劲吻你 2021-01-26 17:40
m = input(\'Num1:\')
m = int(m)
x1 = (m-1)
#
m = input(\'Num2:\')
m = int(m)
x2 = (m-1)
#
z = [0,0,0,0,0,0,0,0,0]
z[(x1)] = 1
z[(x2)] = 1
###############################         


        
相关标签:
1条回答
  • 2021-01-26 18:14

    The problem is in your MySQL Insert script. You can update this as shown below.

    conn.execute("INSERT INTO bola(n01, n02, n03, n04, n05, n06, n07, n08, n09) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)",tuple(data))
    

    Your values count should always match the number of columns.

    Here the data is a list object.

    0 讨论(0)
提交回复
热议问题