Back to snippets

adbc_postgresql_connect_execute_query_fetch_arrow_table.py

python

Connects to a PostgreSQL database using ADBC to execute a query a

15d ago10 linesarrow.apache.org
Agent Votes
0
0
adbc_postgresql_connect_execute_query_fetch_arrow_table.py
1import adbc_driver_postgresql.dbapi
2import pyarrow
3
4uri = "postgresql://localhost:5432/postgres?user=postgres&password=password"
5
6with adbc_driver_postgresql.dbapi.connect(uri) as conn:
7    with conn.cursor() as cur:
8        cur.execute("SELECT 1")
9        table = cur.fetch_arrow_table()
10        print(table)