CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 03:30:43 GMT
content-type: text/html; charset=utf-8
server: cloudflare
access-control-allow-origin: *
cache-control: public, max-age=0, must-revalidate
content-disposition: inline
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=NvrYleKx06U126cVP6z5A7MjuTVDQ5R1fShp6QlL8D536Ng6XiBJCt5PdvHGRxnfOBFZXhmSHFNQq0o4epIB2oQjWf2YVwe0VAYflBsdvsDcBA%3D%3D"}]}
x-matched-path: /docs/sql-client-reference/languages/python
x-vercel-cache: HIT
x-vercel-id: fra1::djk7n-1760239842860-de44db27f4a2
vary: Accept-Encoding
x-varnish: 11927688
age: 268578
via: 1.1 varnish (Varnish/6.5)
x-cache: MISS
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
strict-transport-security: max-age=63072000
cf-cache-status: DYNAMIC
content-encoding: gzip
cf-ray: 98d38524f9c9c795-BOM
alt-svc: h3=":443"; ma=86400
Query Splitgraph from Python with psycopg2 | Splitgraph Try Now
SQL Client Reference

Splitgraph has been acquired by EDB! Read the blog post.
Seafowl NEW!
Try Now
- Add DataExplore DataQuery DataSearch Data
SQL Client Reference
Query Splitgraph from Python with psycopg2
You can use the psycopg2 library to connect to the Data Delivery Network from your Python interpreter or a Jupyter notebook:
import psycopg2
# Your Splitgraph DDN username/password
API_KEY = "API_KEY"
API_SECRET = "API_SECRET"
QUERY = """SELECT candidate_normalized, SUM(votes)::integer AS total_votes
FROM "splitgraph/2016_election:latest".precinct_results
WHERE state_postal = 'CA'
GROUP BY candidate_normalized
ORDER BY total_votes DESC
LIMIT 5
"""
with psycopg2.connect(
dsn=f"postgresql://{API_KEY}:{API_SECRET}@data.splitgraph.com:5432/ddn?application_name=psycopg2"
) as conn:
with conn.cursor() as cur:
cur.execute(QUERY)
result = cur.fetchall()
print(result)
Splitgraph
Splitgraph Inc, registered in Delaware, USA
Splitgraph Limited, registered in England and Wales No. 11657324
Made with
on four continents.