B
B
blizzard2019-03-08 22:09:47
Python
blizzard, 2019-03-08 22:09:47

Why is the table left empty after insert?

For some reason, such code does not produce any error, but the table remains empty. All fields of the table are text
Variables from the loop normally receive a value, i. not empty.

import xml.etree.ElementTree as ET
import sqlite3

conn = sqlite3.connect('employees.sqlite')
tree = ET.parse("Message_ЗК_FL.xml")
root = tree.getroot()
cursor = conn.cursor()



for empl in root.iter('CatalogObject.ФизическиеЛица'):
    empl_id = empl.find('Code').text
    fio = empl.find('ФИО').text
    dob = empl.find('ДатаРождения').text
    gender = empl.find('Пол').text
    cursor = conn.cursor()
    cursor.execute("INSERT INTO zup_employees (id, FIO, DOB, GENDER) VALUES (?, ?, ?,?)", (empl_id, fio, dob, gender))
conn.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AWEme, 2019-03-08
@s41blizzard

conn.commit()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question