Answer the question
In order to leave comments, you need to log in
Why doesn't it write adjacent sqlite columns in the table?
mport sqlite3
import json
def read_sqlite_table():
base = sqlite3.connect('database.db')
cur = base.cursor()
cur.execute('SELECT name FROM list')
reader = cur.fetchmany()
for row in reader:
with open('new_data.json', 'r', encoding='utf-8') as f:
file_content = f.read()
data1 = json.loads(file_content)
d = row[0]
for i in data1:
if d.upper() in i['case_involved'].upper().replace("\"", " ").replace("\'", " "):
news = f"номер:{i['case']}, " \
f"дата:{i['date']}"
cur.execute("INSERT INTO list(description, result) VALUES(?, ?)", (news, 'yes'))
base.commit()
else:
cur.execute("INSERT INTO list(description, result) VALUES(?, ?)", (' ', ' '))
base.commit()
base.close()
if __name__ == '__main__':
read_sqlite_table()
Answer the question
In order to leave comments, you need to log in
INSERT - creates a new entry in the database.
Update needs UPDATE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question