Created
January 22, 2017 07:54
-
-
Save huanzhang/6efa5392456ce188f543491786cdf430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
RS_HOST = 'cmcmbilling.c2upikbi0jsb.ap-northeast-2.redshift.amazonaws.com' | |
RS_PORT = '5439' | |
RS_DB = 'cmcmbilling' | |
RS_USER = '' | |
RS_PASS = '' | |
con = psycopg2.connect(dbname=RS_DB, host=RS_HOST, port=RS_PORT, user=RS_USER, password=RS_PASS) | |
cur = con.cursor() | |
sql = """ | |
SELECT SUM(TO_NUMBER(NULLIF(BTRIM(usagequantity),''),'9999999999D9999999')) | |
FROM car_201612 | |
WHERE usagetype='APS1-DataTransfer-Out-Bytes'; | |
""" | |
cur.execute(sql) | |
cur.fetchone() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment