Skip to content

Instantly share code, notes, and snippets.

@haradreborn
Created November 14, 2014 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haradreborn/1d72c294ac22086a0d3b to your computer and use it in GitHub Desktop.
Save haradreborn/1d72c294ac22086a0d3b to your computer and use it in GitHub Desktop.
fetch rows from postgresql
try:
conn_string = "host='106.109.7.91' dbname='smarttvanalyzer' user='samson' password='samson'"
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
cursor.execute("""SELECT * FROM "IMS" WHERE CAST(date AS DATE) = '""" + ts + "'")
rows = cursor.fetchall()
conn.commit()
for row in rows:
print(row)
except Exception:
print(traceback.format_exc())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment