#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from model import Table
from handler.base_handler import BaseHandler
from threading import Timer
import datetime
class TimeHandler(BaseHandler):
def do_action(self):
update_time = "2018-04-07 18:00:00"
ads_id = "test_1"
t_online = datetime.datetime.strptime(update_time, '%Y-%m-%d %H:%M:%S')
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
t_now = datetime.datetime.strptime(now, '%Y-%m-%d %H:%M:%S')
time_delay = (t_online - t_now).seconds
t1 = Timer(time_delay, self.update, (ads_id, ))
t1.start()
self.result = "success"
return
def update(self, ads_id):
self.db.dsp.query(Table).filter(Table.ads_id == ads_id).update({Table.is_del: 0})
self.db.dsp测试数据mit()
以上就是python 定时修改数据库的示例代码_python的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于python定时修改数据库的示例代码_python的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did84259