123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #!/usr/bin/env python
- #coding=utf-8
- """计算每个电视剧的收视率
- """
- import datetime
- import sys
- from fty_util.common import Mysql
- class tv_avg_ratings_stat():
-
- def province(self):
- conn = Mysql.createOfflineConn()
- sql = """
- truncate table idl.tv_avg_ratings
- """
- Mysql.execute(sql, conn=conn)
- sql = """
- insert into idl.tv_avg_ratings (channel, theater_attribute, tv_name, tv_id, tv_date, value)
- select channel, theater_attribute, tv_name, tv_id, tv_date, value from tmp.tv_avg_ratings
- """
- Mysql.execute(sql, conn=conn)
- Mysql.close(conn)
- def area(self):
- conn = Mysql.createOfflineConn()
- sql = """
- truncate table idl.area_tv_avg_ratings
- """
- Mysql.execute(sql, conn=conn)
- sql = """
- insert into idl.area_tv_avg_ratings (channel, theater_attribute, tv_name, tv_id, tv_date, value)
- select channel, theater_attribute, tv_name, tv_id, tv_date, value from tmp.area_tv_avg_ratings
- """
- Mysql.execute(sql, conn=conn)
- Mysql.close(conn)
- if __name__ == '__main__':
- if len(sys.argv) != 2:
- print '没有输入参数,退出'
- sys.exit(0)
- print 'method name is ' + sys.argv[1]
- obj = tv_avg_ratings_stat()
- try:
- getattr(obj, sys.argv[1])()
- except Exception, e:
- print e
|