Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
titleConnecting to Canopy Data Eco-System using Python
linenumberstrue
collapsetrue
import psycopg2
from psycopg2 import extras

# database credentials
database_host_url = 'abcd.amazon.com'
database_name = 'abcd1234'
database_username = 'polo5678'
database_pwd = 'password'

# Login to PostgreSQL database
canopy_postgresql_conn = psycopg2.connect(dbname=database_name, user=database_username, host=database_host_url, password=database_pwd)
canopy_postgresql_conn.autocommit = True

with canopy_postgresql_conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as temp_cursor:
    temp_cursor.execute("select * from consolidated_holdings limit 5;")
	results = temp_cursor.fetchall()

for row in results:
	print (row)

...