We may encounter the following error when adding information to the database:
Column does not match value COUNT COUNT AT Row 1
of the error mean values and the number of incoming field value table is not the same as the number of
I sum up a bit, there are three error-prone points:
1. To the incoming values of the number of fields and the following values in the table are not equal number.
eg: a table in the following six fields:
we want to insert a row of data, the data will be passed in this line id_card
, passwd
two fields. ( name
, problem
, answer
Can be empty)
sql = "insert into user(id_card, passwd) values({}, '{}', '{}');".format(a, b, c)
To pass table user
is id_card
and the passwd
field, but behind the values you gave him a
, b
, c
three values. It should correspond to the only two values.
2.values field type and value types defined in the table do not match
For example, we have the following code:
sql = "insert into user(id_card, passwd) values({}, '{}';".format(127, '111')
As defined in Table I id_card
is a string type, but here is the incoming integer. Does not match.
In addition, say one more thing: here values
independent of the type and value of the incoming parameter type.
For example: values({})
This is an integer, values('{}')
which is a type of string
type in the difference of emphasis values
in {}
including whether single quotes together, if that is enclosed in the string is not an integer. And with format()
nothing to do in the parameter type.
3. Note the commas, parentheses, semicolons should use American's do not pay attention to the written Chinese language! ! ! ! ! ! !
I find this is a mistake 30 minutes, thought it was code field and other reasons, the result is not! ! ! ! ! !