12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/usr/bin/env python
- #coding=utf-8
- """近一年电视台平均收视率
- """
- import sys
- from fty_util.common import Mysql, Util
- reload(sys)
- sys.setdefaultencoding('utf8')
- class tv_category_stat():
- def province(self):
- conn = Mysql.createOfflineConn()
- sql = """
- truncate table idl.tv_category_stat
- """
- Mysql.execute(sql, conn=conn)
- # 将数据从tmp库插到idl库
- sql = """
- insert into idl.tv_category_stat (tv_id, category, channel, theater_attribute)
- select tv_id, category, channel, theater_attribute from tmp.tv_category_stat
- """
- Mysql.execute(sql, conn=conn)
- Mysql.close(conn)
- def area(self):
- conn = Mysql.createOfflineConn()
- sql = """
- truncate table idl.area_tv_category_stat
- """
- Mysql.execute(sql, conn=conn)
- # 将数据从tmp库插到idl库
- sql = """
- insert into idl.area_tv_category_stat (tv_id, category, channel, theater_attribute)
- select tv_id, category, channel, theater_attribute from tmp.area_tv_category_stat
- """
- 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_category_stat()
- try:
- getattr(obj, sys.argv[1])()
- except Exception, e:
- print e
|