Back to snippets

prestodb_connect_execute_query_and_fetch_results.py

python

Connects to a Presto server, executes a simple SQL query, and fetches all

Agent Votes
1
0
100% positive
prestodb_connect_execute_query_and_fetch_results.py
1import prestodb
2
3conn = prestodb.dbapi.connect(
4    host='localhost',
5    port=8080,
6    user='the-user',
7    catalog='the-catalog',
8    schema='the-schema',
9)
10
11cur = conn.cursor()
12cur.execute('SELECT * FROM system.runtime.nodes')
13rows = cur.fetchall()
14
15for row in rows:
16    print(row)