FAQ
hi,
I am creating a function inside the views.py, I want to call this
function automatically according to timing which i m using through
apscheduler. how is it possible, please tell me.....
my views.py file....
# Create your views here.
import simplejson as json
from apps.learning.models import CourseCategory
import sys
from apscheduler.scheduler import Scheduler
import tkMessageBox


sched = Scheduler()
sched.start()


def JsontoMySQL():
category_json_data = json.load(open('DataCategory.json','r'))
tkMessageBox.showinfo(title="Greetings", message="Hello World!")
category = CourseCategory()
for i in range(0,len(category_json_data)-1):
cats_id = category_json_data[i]['cats_id']
cats_name = category_json_data[i]['cats_name']
cats_short_name = category_json_data[i]['cats_shortname']
category = CourseCategory(cats_id=cats_id, cats_name=cats_name,
cats_short_name=cats_short_name)
category.save()

def job_function():
JsontoMySQL()

sched.add_cron_job(job_function, month='1-12', day='1-31',
hour='0-23',minute='34-36')


Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Avnesh Shakya at May 3, 2013 at 10:05 am
    hi, please tell me. it's urgent.
    On Thursday, May 2, 2013 7:01:33 PM UTC+5:30, Avnesh Shakya wrote:


    hi,
    I am creating a function inside the views.py, I want to call this
    function automatically according to timing which i m using through
    apscheduler. how is it possible, please tell me.....
    my views.py file....
    # Create your views here.
    import simplejson as json
    from apps.learning.models import CourseCategory
    import sys
    from apscheduler.scheduler import Scheduler
    import tkMessageBox


    sched = Scheduler()
    sched.start()


    def JsontoMySQL():
    category_json_data = json.load(open('DataCategory.json','r'))
    tkMessageBox.showinfo(title="Greetings", message="Hello World!")
    category = CourseCategory()
    for i in range(0,len(category_json_data)-1):
    cats_id = category_json_data[i]['cats_id']
    cats_name = category_json_data[i]['cats_name']
    cats_short_name = category_json_data[i]['cats_shortname']
    category = CourseCategory(cats_id=cats_id, cats_name=cats_name,
    cats_short_name=cats_short_name)
    category.save()

    def job_function():
    JsontoMySQL()

    sched.add_cron_job(job_function, month='1-12', day='1-31',
    hour='0-23',minute='34-36')


    Thanks in advance.
    --
    You received this message because you are subscribed to the Google Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Tom Evans at May 3, 2013 at 10:30 am

    On Fri, May 3, 2013 at 11:04 AM, Avnesh Shakya wrote:
    hi, please tell me. it's urgent.
    "its urgent".

    Sorry, couldn't resist. As this seems to have nothing to do with
    django, and a lot to do with "apscheduler", perhaps you should ask the
    apscheduler folks instead?

    Cheers

    Tom

    --
    You received this message because you are subscribed to the Google Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Avnesh Shakya at May 3, 2013 at 10:37 am
    thanks but if i want to get a function called autometically, when i run
    127.0.0.1:8000/ which defined inside views.py. how is it possible.

    On Fri, May 3, 2013 at 4:00 PM, Tom Evans wrote:
    On Fri, May 3, 2013 at 11:04 AM, Avnesh Shakya wrote:
    hi, please tell me. it's urgent.
    "its urgent".

    Sorry, couldn't resist. As this seems to have nothing to do with
    django, and a lot to do with "apscheduler", perhaps you should ask the
    apscheduler folks instead?

    Cheers

    Tom

    --
    You received this message because you are subscribed to the Google Groups
    "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Timothy Makobu at May 3, 2013 at 11:07 am
    I would do this by having the view exposed on a url like 127.0.0.1:8000/myview
    and having that called from cron via curl, a python script utilizing urllib.

    On Fri, May 3, 2013 at 1:37 PM, Avnesh Shakya wrote:

    thanks but if i want to get a function called autometically, when i run
    127.0.0.1:8000/ which defined inside views.py. how is it possible.

    On Fri, May 3, 2013 at 4:00 PM, Tom Evans wrote:

    On Fri, May 3, 2013 at 11:04 AM, Avnesh Shakya <avnesh.nitk@gmail.com>
    wrote:
    hi, please tell me. it's urgent.
    "its urgent".

    Sorry, couldn't resist. As this seems to have nothing to do with
    django, and a lot to do with "apscheduler", perhaps you should ask the
    apscheduler folks instead?

    Cheers

    Tom

    --
    You received this message because you are subscribed to the Google Groups
    "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups
    "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/django-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdjango-users @
categoriesdjango, python
postedMay 2, '13 at 1:31p
activeMay 3, '13 at 11:07a
posts5
users3
websitedjangoproject.com

People

Translate

site design / logo © 2022 Grokbase