Commit 66b00f1334f17d1637ddf6b8efc005f824af263b

Authored by Noah ago
1 parent 86365c78ee
Exists in master

저장까지 일단 모두 종료

Showing 1 changed file with 25 additions and 15 deletions Side-by-side Diff

... ... @@ -23,17 +23,13 @@
23 23  
24 24 for content in contents_list:
25 25  
26   - print content['id']
27   - print content['created_time'].replace('T'," ").replace('+0000',"")
28   - print content['message'].replace('\n',"").replace('\r',"").replace('\'',"")
  26 + id = content['id']
  27 + created_time = content['created_time'].replace('T'," ").replace('+0000',"")
  28 + message = content['message'].replace('\n',"").replace('\r',"").replace('\'',"")
29 29  
30 30 insight = Insight(token)
31 31 insight.setContentInsight(content['id'])
32   - lists =["id",
33   - "message",
34   - "created_time",
35   - "loging_time",
36   - "post_story_adds_unique",
  32 + lists =["post_story_adds_unique",
37 33 "post_story_adds",
38 34 "post_story_adds_by_action_type_unique,comment",
39 35 "post_story_adds_by_action_type_unique,like",
... ... @@ -61,7 +57,7 @@
61 57 "post_video_views",
62 58 "post_video_views_unique",
63 59 "post_video_views_paid",
64   - "post_video_views_autoplayed"
  60 + "post_video_views_autoplayed",
65 61 "post_video_views_10s",
66 62 "post_video_views_10s_unique",
67 63 "post_video_views_10s_paid",
68 64  
69 65  
70 66  
... ... @@ -74,17 +70,31 @@
74 70 "post_video_complete_views_organic",
75 71 "post_video_complete_views_paid"]
76 72  
77   - sqlprefix = "insert into facebook_insights ("
  73 + sqlprefix = "insert into facebook_insights2 ("
78 74 sqlvalues = " values ("
  75 +
  76 + sqlprefix += "`id`, "
  77 + sqlprefix += "`message`, "
  78 + sqlprefix += "`created_time`, "
  79 + sqlprefix += "`loging_time`, "
  80 +
  81 + sqlvalues += "'" + id + "', "
  82 + sqlvalues += "'" + message + "', "
  83 + sqlvalues += "'" + created_time + "', "
  84 + sqlvalues += "NOW(), "
  85 +
79 86 for list in lists:
80   - print list, insight.getContentInsightByKey(list)
81   - sqlprefix = sqlprefix + "`" + list.replace(',','_') + "`, "
82   - sqlvalues = sqlvalues + str(insight.getContentInsightByKey(list)) + ", "
  87 + #print list, insight.getContentInsightByKey(list)
  88 +
  89 + sqlprefix += "`" + list.replace(',','_') + "`, "
  90 + print list.replace(',','_')
  91 + sqlvalues += str(insight.getContentInsightByKey(list)) + ", "
  92 +
83 93 sqlprefix = sqlprefix[:len(sqlprefix)-2] + ")"
84 94 sqlvalues = sqlvalues[:len(sqlvalues)-2] + ");"
85 95  
86   - # datadb = DataDB()
87   - # datadb.fb_insert(sqlprefix + sqlvalues)
  96 + datadb = DataDB()
  97 + datadb.fb_insert(sqlprefix + sqlvalues)
88 98 print sqlprefix + sqlvalues
89 99  
90 100