I have following code:
class Country(models.Model):
name = models.CharField(max_length = 200, primary_key = True)
# ORM variant
for name in file:
models.Country(name = name).save()
# cursor variant
for name in file:
if cursor.execute("select * from app_country where name = %s",
(name,)) == 0:
cursor.execute("insert into app_country (name) values (%s)",
(name,))
Code with cursor runs 100x faster than ORM code.
Even if I'm doing so:
for name in file:
if cursor.execute("select * from app_country where name = %s",
(name,)) == 0:
cursor.execute("insert into app_country (name) values
(%s)", (name,))
else:
cursor.execute("delete from app_country where name =
%s", (name,))
cursor.execute("insert into app_country (name) values
(%s)", (name,))
this is 5x faster than work with ORM.
Where am I doing mistake in using Django ORM?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---