mysql reverting the entered data...

32 views
Skip to first unread message

JAI PRAKASH SINGH

unread,
Jan 12, 2015, 1:32:18 AM1/12/15
to python-mysql...@googlegroups.com
hello all, 
    
    please reply 

    1) I wrote a code n python using django orm, 
    2) to enter the url entry in mysql db,  
    3) and this code enters the data (url) in mysql db 
    4) and code exists fine 
  
    but 

    when i see the database it revert back , i.e there is no data after some time ,  i don't understand y it happens. 

my code is under 
#################################

def unit_url_creater_with_page():
        tab_list = ['info', 'listings', 'photos', 'plans', 'prices', 'payments', 
               'specifications', 'documents', 'local']
unit_cont_type = ContentType.objects.get(app_label="main", model="Unit")
unit_cont_type_id = unit_cont_type.id
        
unitobj = Unit.objects.all()

for uobj in unitobj:
       ret_dict_for_url = unit_url(uobj)

       main_url = ret_dict_for_url["url"]
       main_url = "/".join(filter(None, main_url.lower().split("/")))
       main_url = "/%s/" %("-".join(main_url.split()))

                meta_description = ret_dict_for_url["meta_description"]
                meta_title = ret_dict_for_url["meta_title"]
                meta_keywords = ret_dict_for_url["meta_keywords"]
         
                pobj, pobj_bool = Page.objects.get_or_create( url = main_url, 
                                  entity_type_id= unit_cont_type_id,
                                  entity_id = uobj.id
 meta_description = meta_description, 
 meta_title = meta_title, 
 meta_keywords = meta_keywords)

       if pobj_bool:
   print pobj.url

                for url_last_word in tab_list:
           url_now = "%s%s/" %(main_url, url_last_word)
   
           pobj, pobj_bool = Page.objects.get_or_create( url = url_now, 
                         entity_type_id= unit_cont_type_id,
           entity_id = uobj.id
 meta_description = meta_description, 
 meta_title = meta_title, 
 meta_keywords = meta_keywords)
           if pobj_bool:
       print pobj.url

print "#"*124
        print "the end"


Reply all
Reply to author
Forward
0 new messages