Chinaunix首页 | 论坛 | 博客
  • 博客访问: 104235
  • 博文数量: 14
  • 博客积分: 1475
  • 博客等级: 上尉
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-03 23:33
文章分类

全部博文(14)

文章存档

2007年(14)

我的朋友

分类: Python/Ruby

2007-05-04 08:58:29

    Q:
 
    本人希望写一个Python程序用于每天统计当天在数据库中插入数据的条数,建立odbc后,想在每天的23:59分执行计划任务来执行这个程序:
    e.cur.execute('select count(*) from testtable where reg_date >= \'2004-12-19\'')
    但我希望每次执行的时间为当天的日期,而不是需要每次执行计划任务时手动调节程序:
    reg_date >= "2004-12-20"
    请教如何在reg_date插入一个time,能取当天的年月日.
 
    A:
 
    from time import strftime
    ...
    e.cur.execute("select count(*) from testtable where reg_date >= '%s'" % strftime('%Y-%m-%d'))
 
阅读(1546) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~