'pymysql.err.DataError: (1366, "Incorrect integer value:
Getting this error, while trying to sent information to database via this code in python:
with open('ypatybes_paruosta.csv', encoding='utf-8') as data2:
csvreader = csv.reader(data2, delimiter = ';')
next(csvreader)
for row in csvreader:
print(row)
cursor.execute(
'INSERT INTO flat_features(flat_id, features_id) VALUES (%s, %s)', row)
conn.commit()
cursor.close()
There's only to values, but one of the value (feature_id), have empty value. And for some reason it doesnt like it.
This is what i see in output window before getting mentioned error:
['1', '5']
['2', '5']
['2', '3']
['3', '']
Can someone help with that ? Thanks !
P.S. I saw solution here python mysql script: DataError: (1366, "Incorrect integer value: but it doesnt help in my case
Table creation code in mysql:
CREATE TABLE flat_features(
flat_features_id int NOT NULL AUTO_INCREMENT,
flat_id INT NOT NULL,
features_id INT NOT NULL,
PRIMARY KEY(flat_features_id),
CONSTRAINT fk_flat_features FOREIGN KEY(flat_id) REFERENCES flats(flat_id) ON UPDATE CASCADE,
CONSTRAINT fk_featuresID FOREIGN KEY(features_id) REFERENCES features(features_id) ON UPDATE CASCADE
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
