Skip to content

Commit

Permalink
Merge pull request mozilla-services#1179 from selenamarie/bug860026-s…
Browse files Browse the repository at this point in the history
…ync-adu

bug 860026 add sync_raw_adu.py to repo
  • Loading branch information
selenamarie committed Apr 9, 2013
2 parents c142d55 + 6b7c29b commit 0d44bb6
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# In production on stage db

import os
from os.path import join, getsize
import sys
Expand All @@ -17,8 +19,8 @@
csd_cur.execute("""SELECT COUNT(*) FROM raw_adu WHERE "date" = 'yesterday'::date""")

if (csd_cur.fetchone()[0]) > 0:
sys.stderr.write('raw_adu has already been exported for yesterday')
sys.exit(-1)
sys.stderr.write('raw_adu has already been exported for yesterday')
sys.exit(-1)

#connect to replayDB
replay = psycopg2.connect("dbname=breakpad user=postgres port=5499")
Expand All @@ -27,13 +29,13 @@
# check if we already have ADU for the day
rep_cur.execute("""SELECT count(*) FROM raw_adu WHERE "date" = 'yesterday'::date""")

if (rep_cur.fetchone()[0]) = 0:
sys.stderr.write('no raw_adu in replayDB for yesterday')
sys.exit(-2)
if (rep_cur.fetchone()[0]) == 0:
sys.stderr.write('no raw_adu in replayDB for yesterday')
sys.exit(-2)

#dump raw_adu to file
rep_cur.execute("""COPY ( SELECT * FROM raw_adu WHERE "date" = 'yesterday'::date )
TO '/tmp/raw_adu_update.csv' with csv;""")
rep_cur.execute("""COPY ( SELECT * FROM raw_adu WHERE "date" = 'yesterday'::date )
TO '/tmp/raw_adu_update.csv' with csv;""")
replay.close()

#import raw_adu into CSD
Expand All @@ -44,7 +46,3 @@
print 'raw_adu successfully updated'

sys.exit(0)




0 comments on commit 0d44bb6

Please sign in to comment.