Home Django Mysql querying in loop but getting same output
Reply: 0

Django Mysql querying in loop but getting same output

user606
1#
user606 Published in June 25, 2018, 4:05 am

This below code in Django is printing same results all the time. Even if there are more rows in the mysql DB. Please Help.

    while True:
        print Event.objects.last().id
        time.sleep(5)

====edit==== There was something important I missed. The above is giving proper results but below one is not. I am using slave db here to read. But question still remains the same. Does this mean that there is some slave db configuration that is creating problem?

    while True:
        print Event.objects.using("read").last().id
        time.sleep(5)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.303118 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO