Python Resources - Basic Python, ML, DataScience, BigData
2.41K subscribers
14 photos
3 files
243 links
You can find all kinds of resources related to Python, ML, DataScience and BigData.
Resources — »»» @python_resources_iGnani
Projects — »»» @python_projects_repository
Questions— »»» @python_interview_questions
Forum — »»» @python_programmers_club
Download Telegram
Connecting to Amazon Redshift database and Inserting data

import psycopg2
con=psycopg2.connect(dbname= 'dbname', host='host', port= 'port', user= 'user', password= 'pwd')

#once the above code executes and connection is established
# create a cursor
cur = con.cursor()

#now you can execute select statements
cur.execute("SELECT * FROM employee;")

#Next you need to instruct Psycopg how to fetch your data
cur.fetchall()

#Finally, don't forget to close your cursor & connection
cur.close()
conn.close()

#python #sampleCode #amazon #redshift