Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:33:30+00:00 2026-06-01T15:33:30+00:00

I am using sqlalchemy job store in APS . Jobs are added too cron

  • 0

I am using sqlalchemy job store in APS . Jobs are added too cron using the function add_cron_job. But no entry is made in database table. Pls help me out: following is the code

import time
import logging
from threading import Timer
from threading import Lock
from gadgetplatform.classes.utils.utilities import import_module
from apscheduler.scheduler import Scheduler

from apscheduler.jobstores.sqlalchemy_store import SQLAlchemyJobStore

class SchedulerManager(object):
    _instance = None
    _initialised = False
    lock = Lock()
    log = logging.getLogger(__name__)
    jobDict=[]

    def __new__(cls):

        if not cls._instance or not cls._initialised:
            cls.lock.acquire()
            if not cls._instance:
                cls.log.info("creating instance")
                cls._instance = super(SchedulerManager, cls).__new__(cls)
                cls._initialised = True
                cls._instance.init()
                cls.log.info("instance created")
            cls.lock.release()
            cls.log.info("lock released")
            cls.log.info("returning instance")
        return cls._instance    

    def init(self):
        self.sched=Scheduler()
        self.sched.add_jobstore(SQLAlchemyJobStore('mysql://root@localhost/mygola?charset=utf8&use_unicode=0'), 'apschedulerJobs')        

    def addToCron(self,source,time):
        self.log.info("called to add schedular")

        time = time.split(' ')

        m=str(time[0])        
        h=str(time[1])        
        d=str(time[2])        
        mnth=str(time[3])                
        yr=str(time[4])

        func=self.convertStringToFunction(source)
        self.sched.add_cron_job(func, year=yr, month=mnth, day=d, hour=h, minute=m)        
        self.jobDict.append(source)

        self.log.info("added with the time")            

    def removeFromCron(self,source):        
        func=self.convertStringToFunction(source)
        self.sched.unschedule_func(func)

    def start(self):
        self.sched.start()
        self.log.info("Schedular Started")

    def stop(self):
        self.sched.shutdown()

    def getRunningJobs(self):
        return self.jobDict

    def convertStringToFunction(self,source):
        strArr = source.rsplit('.',1)
        mod = import_module(strArr[0])
        func = getattr(mod, strArr[1])
        return func
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:33:31+00:00Added an answer on June 1, 2026 at 3:33 pm

    I have never used APScheduler, but from the docs, it looks as if you have to specify what job store to add a job to.

    You can either make sure that the SQL Alchemy job store is the default one by giving it the special name default:

    self.sched.add_jobstore(SQLAlchemyJobStore('...'), 'default')
    

    Or you can specify the job store name when adding a job:

    self.sched.add_cron_job(func, 
                            jobstore="apschedulerJobs", 
                            year=yr, month=mnth, day=d, hour=h, minute=m)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to map an object to a database using SQLAlchemy but have
I am using a relational database via SQLAlchemy. I want to spawn a job
Is it possible to have the postgres database dump(pg_dump) using SQLAlchemy? i can get
I'm trying to do a two-phase commit using SQLalchemy 0.6.8 with Postgresql 8.3.4, but
I am using SqlAlchemy, a python ORM library. And I used to access database
I have recently started using SQLALCHEMY to query a my-sql database. I want to
I'm using SqlAlchemy to store some objects with a DateTime field: my_date = Field(DateTime())
I create a table in database using sqlalchemy and now want to make a
I was walking view definitions in a database today using sqlalchemy 0.6 (using get_view_definition())
How I should set up this SQL database. I am using SQLAlchemy with SQLite.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.