0

I am extracting info from XYZ website and save it to sqlite. I want this process repeat every 15 minutes. So my code:

import numpy as np
import pandas as pd
import datetime
import urllib
from bokeh.models import HoverTool
from collections import OrderedDict
import sqlite3
from sqlalchemy import create_engine
from apscheduler.schedulers.background import BackgroundScheduler

def get_data():
    query = ("WEBSITE_ADDRESSCOM/XYZ.json")
    raw_data = pd.read_json(query)
    conn = sqlite3.connect('X.db')
    c = conn.cursor()
    disk_engine = create_engine('sqlite:///X.db')
    raw_data.to_sql('table', disk_engine, if_exists='append')
    print("I downloaded", pd.read_sql_query('SELECT * FROM 
    table',disk_engine).shape[0],"cases")
    conn.close()

scheduler = BackgroundScheduler()
scheduler.add_job(get_data, 'interval', minutes=15)
scheduler.start()

But it gives me this error.

LookupError: No trigger by the name "interval" was found

This code works on Windows. I am trying on Mac now (with Python 3) but it gives above error although I followed recommendations on this link No trigger by the name "interval" was found.

2
  • So... what line did this error occur on? Commented Dec 11, 2017 at 17:35
  • I think scheduler.add_job(get_data, 'interval', minutes=15) Commented Dec 11, 2017 at 17:36

1 Answer 1

1

Here is what I did and it worked on Mac too.

I updated setuptools as outlined here: No trigger by the name "interval" was found

Then I run below code.

sudo -H pip  install --ignore-installed apscheduler

I am not sure if that is relevant but I restarted the kernel after this procedure and now it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.