views:

34

answers:

1

hi guys, I encountered an error when doing the following retrieval:

class status(models.Model):
    pid = models.IntegerField()
    phase = models.TextField()
    rejected = models.IntegerField()
    accepted = models.IntegerField()
    type = models.IntegerField(default=1)
    date = models.DateTimeField(primary_key = True)
    time_taken = models.IntegerField(null = True)

    class Meta:
        db_table = "crawl_status_ss"

query:

    statusIn = status.objects.get(pid=12345,phase='crawling')

Error:

django.db.utils.DatabaseError: current transaction is aborted, commands ignored
until end of transaction block

Does anyone knows whats the reason?

EDIT:

In my previous section of my code, I have an exception when inserting an entry to another table, but i caught the exception:

for entry in blogEntries:        
            link = entry['link'].encode('utf-8')
            title = entry['title'].encode('utf-8')
            date1 = entry['date'][:10].encode('utf-8')
            content = entry['content'].encode('utf-8')
            try:
                post = postTitle(site_id=url,post_url=link,post_title=title)
                post.save()
                postId = post.post_id

                hashString = getMD5Hash(content)

                blogContent = postContent(post_content=content,post_id=post,hash=hashString,site_id = url,post_date=date1)
                blogContent.save()

            except:
                print 'Error:' + str(sys.exc_value)
                continue
+1  A: 

Django stats a database transaction for your view. So when you catch the exception, it means the transaction is in a failed state and you can't run any more SQls. You should really try to figure what the actual problem is when it fails either in your post.save or blogContent.save methods. If you really don't care (since you just catch the exception and continue), you should manage transactions yourself. See the docs for help on this:

ars
got it. thanks...
goh