|
@@ -9,6 +9,7 @@ from oauth2client.service_account import ServiceAccountCredentials
|
|
|
import os, dataset, json, gspread
|
|
|
from gspread_pandas import Spread, Client
|
|
|
import pandas as pd
|
|
|
+from fastapi_utils.tasks import repeat_every
|
|
|
|
|
|
app = FastAPI()
|
|
|
directory=os.path.dirname(os.getcwd())
|
|
@@ -79,4 +80,10 @@ def save_sheet(df,filename,tabname,startpos='A1'):
|
|
|
async def getbookingdata(bgtask: BackgroundTasks):
|
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/violetbeauty?charset=utf8mb4')
|
|
|
bgtask.add_task(getdata, db)
|
|
|
- return '資料取出中...'
|
|
|
+ return '資料取出中...'
|
|
|
+
|
|
|
+@app.on_event("startup")
|
|
|
+@repeat_every(seconds=60)
|
|
|
+def update_booking():
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/violetbeauty?charset=utf8mb4')
|
|
|
+ getdata(db)
|