STATSML 100: Python & JupyterLab Setup for Data Distiller
Learn how to setup Python and JupyterLab to connect to Data Distiller.
Last updated
jupyter labimport psycopg2;
conn = psycopg2.connect('''sslmode=require host=<YOUR_HOST_CREDENTIAL> port=80 dbname=prod:all user=<USERNAME> password=<YOUR_PASSWORD>''')import psycopg2;
# Establish a connection to the database
conn = psycopg2.connect('''sslmode=require host=ZZZZ port=80 dbname=prod:all user=YYYYY@AdobeOrg password=XXXXX''')
# Create a cursor object for executing SQL commands
cursor = conn.cursor()
# Example query
query = "SELECT * FROM movie_data;"
cursor.execute(query)
# Fetch all the results
# results = cursor.fetchall()
# Fetch the results in chunks
chunk_size = 50
while True:
# chunk is a cursor that fetches 50 rows at a time. It is not a running index.
chunk = cursor.fetchmany(chunk_size);
# Break the while loop if there are no rows to be fetced
if not chunk:
break
# Print each row. Print by default is a newline.
for row in chunk:
print(row);
# Close the cursor and connection
cursor.close()
conn.close()