Last active
August 29, 2015 14:00
-
-
Save wadewegner/6aa1c8a8e864cdcb4cf7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
import psycopg2 | |
import urlparse | |
urlparse.uses_netloc.append("postgres") | |
url = urlparse.urlparse(os.environ["DATABASE_URL"]) | |
conn = psycopg2.connect( | |
database=url.path[1:], | |
user=url.username, | |
password=url.password, | |
host=url.hostname, | |
port=url.port | |
) | |
cur = conn.cursor() | |
cur.execute('INSERT INTO iot_monitortemps.readings__c (celsius__c, fahrenheit__c, readingdatetime__c) ' + | |
'VALUES (%s, %s, %s)', | |
(25.2225819147,83.261394157,'2014-05-02 21:39:12.795193+00:00')) | |
cur.execute('select * from iot_monitortemps.readings__c') | |
rows = cur.fetchall() | |
print "\nShow me the records:\n" | |
for row in rows: | |
print " ", row[1] | |
conn.commit() | |
cur.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment