Answer the question
In order to leave comments, you need to log in
Prepare queries to be added in a loop?
I would like to know if it is possible in django to prepare requests for adding in a cycle, and after the cycle, send this request to add records to the database.
At the moment, I have the following added to the database:
for value in _history:
History.objects.create(
description = value['description']
)
for value in _history:
with connection.cursor() as cursor:
cursor.execute("INSERT INTO `history`(`description`) VALUES (%(description)s)", {
"description": value["description"]
})
connection.commit()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question