4

I have created a cronjob in Python. The purpose is to insert data into a table from another one based on certain conditions. There is more than 65000 record to be inserted. I have executed the cronjob and has seen more than 25000 records inserted. But after that the record are getting automatically deleted from that table. Even the records that has already inserted into the table that day before executing the cronjob is getting deleted. "The current database is hosted in Xeround cloud." Is MySQL doing so, i.e some kind of rollback or something

Does anybody have any idea about this. Please give me a solution. Thanks in advance..

SkariaArun
  • 219
  • 1
  • 13
  • How is data inserted? Via plain insert query or stored proc? – DevelopmentIsMyPassion Mar 11 '13 at 06:46
  • Its just a plain insert.. – SkariaArun Mar 11 '13 at 06:48
  • Can you show that query? – DevelopmentIsMyPassion Mar 11 '13 at 06:51
  • I'm doing this via Django and i'm using its ORM..You mean the entire cronjob. – SkariaArun Mar 11 '13 at 06:55
  • Ok sorry then i dont know about Django. But i am sure you will get some help – DevelopmentIsMyPassion Mar 11 '13 at 07:16
  • It seems your transaction fails and ends with rollback. Check your transaction policy. – dani herrera Mar 11 '13 at 08:35
  • Would you please explain this in some more deatil. – SkariaArun Mar 11 '13 at 09:07
  • @SkariaArun, sql sentences are enclosed into transaction. When transaction finish without issues, all changes are commited to database (This is the `A` of the `ACID` transaction behavior). I some problem occurs into transation, all changes are rolled back. This is a **simplified** approach. You should [learn in deepth about transaction](https://docs.djangoproject.com/en/dev/topics/db/transactions/). With django you can manage [transactions by hand](https://docs.djangoproject.com/en/dev/topics/db/transactions/#django.db.transaction.commit_manually), set a transaction behavior, work with a mix. – dani herrera Mar 11 '13 at 10:36
  • @danihp, Thanks a lot...I'm inserting data for a set of unique IDs..At a point of time, records for about half of the IDs were inserted into the database table. But later when i checked, all the entries except the record for the last ID got deleted. Any idea on this.? – SkariaArun Mar 11 '13 at 11:22
  • @SkariaArun, my final question. Ar you sure you are using heroku's mysql? Perhaps are you storing your data in filesystem in some way? – dani herrera Mar 11 '13 at 14:33
  • @danihp Sorry our project is hosted in Heroku. And our database is hosted in 'Xeround' cloud.. – SkariaArun Mar 12 '13 at 09:34
  • 2
    Perhaps you have deletes in other parts of the database and linked models? Check out the [cascade on delete](https://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects) options for Django. – Austin Phillips Mar 12 '13 at 10:40
  • @AustinPhillips Thanks...But there are no foreign key relationships. – SkariaArun Mar 12 '13 at 10:54

1 Answers1

1

Run your django orm statement in the django shell and print the traceback. Look for delete statements in the django traceback sql.

hobs
  • 18,473
  • 10
  • 83
  • 106