docs / drivers-python
On this page
Python driver
Python 3.10+ (stdlib only — socket, ssl, decimal, json; no external dependencies). Path: `drivers/python`. Not published to PyPI — import it from this tree directly.
Remote TLS:
For --require-client-key, pass key=client_root_32_bytes (a bytes object). Never put keys or passwords in a URL.
Types
None ↔ SQL NULL; bool/int/float/decimal.Decimal/str map as expected (int/float/Decimal all encode as DECIMAL); uuid.UUID for UUID columns; datetime.datetime for TIMESTAMPTZ (naive datetimes are treated as UTC); a list[float] (or nextsql.Vector for sparse vectors) for VECTOR/SPARSEVECTOR; dict/list for JSON (encoded as a JSON string parameter, decoded from the server's binary JSON on the way back); nextsql.Point/Box/Line/Polygon for the spatial types.
Cluster routing
nextsql.connect_cluster(nextsql.Config(nodes=[...], read_consistency=nextsql.READ_BOUNDED)) returns a Cluster that sends eligible reads to a healthy follower and everything else to the leader, failing over on a leader change. See HA / consistency.