client-python
is a library to access Service Binding Specification for Kubernetes conformant Service Binding Workload Projections.
import psycopg2 as psycopg2
from bindings import bindings
b = bindings.from_service_binding_root()
b = bindings.filter(b, "postgresql")
if len(b) != 1:
raise ValueError("Incorrect number of PostgreSQL bindings: %s" % len(b))
u = b[0].get("url")
if u is None:
raise ValueError("No URL in binding")
conn = psycopg2.connect(u)
# ...
Apache License v2.0: see LICENSE for details.