Answer the question
In order to leave comments, you need to log in
How to get the result of executing a SQL query in Python?
For example, there is a sql query:
INSERT INTO categories(category, sub_category)
SELECT category, sub_category
FROM (SELECT "category" as category, "Final" as sub_category) temp
WHERE NOT EXISTS (SELECT 1 FROM categories WHERE categories.category = temp.category AND categories.sub_category = temp.sub_category)
async with aiosqlite.connect('categories.db') as db:
await db.execute(sql)
await db.commit()
Result: Request completed successfully. Took 1ms, 1 lines changed
print(await db.execute(sql))
print(await db.commit)
status = await db.fetch()
print(status)
Answer the question
In order to leave comments, you need to log in
Judging by the office. there is no documentation for such a function and the only way is something like this:
if db.total_changes > 0:
print('Insertion category {} with sub_category {} complete'.format(value, categories[index]))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question