Skip to content

Instantly share code, notes, and snippets.

@huanzhang
Created January 22, 2017 07:54
Show Gist options
  • Save huanzhang/6efa5392456ce188f543491786cdf430 to your computer and use it in GitHub Desktop.
Save huanzhang/6efa5392456ce188f543491786cdf430 to your computer and use it in GitHub Desktop.
#!/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