Python Driver: Polypheny

The polypheny module exports connect(), the Connection and Cursor classes, DB-API constants, value constructors and exception classes. Obtain a connection from connect() and a cursor from that connection.

connect()

polypheny.connect(address=None, *, username=None, password=None, transport=None, **kwargs) returns a connected Connection with auto-commit disabled.

Parameter Meaning
address A (hostname, port) tuple for plain or a socket path string for unix.
username Prism username. Omit it to use peer authentication with a Unix socket.
password Prism password. When supplying a username, also supply the password, even if it is an empty string.
transport Either "plain" or "unix".
**kwargs Reserved. Connector 2.0.0 consumes no additional transport options.

Call polypheny.connect() with no arguments to use the default Unix socket at ~/.polypheny/polypheny-prism.sock. For any explicit settings, supply both address and transport. To include credentials with a Unix socket connection, pass the expanded path as the address, for example with str(Path.home() / ".polypheny" / "polypheny-prism.sock") from pathlib.

Transports

  • plain uses unencrypted TCP. Supply a username and password. Use a trusted network or a secure tunnel, and connect to a running plain Prism listener.
  • unix uses a local Unix domain socket. It requires a Unix socket listener and filesystem access to its path. Use the actual socket path configured on the server.

Module constants

Name Value Meaning
apilevel "2.0" The Python DB-API level. The Prism API version is negotiated separately.
threadsafety 0 Thread sharing is unsupported by the DB-API declaration. Keep connections and cursors within one thread.
paramstyle "qmark" SQL positional parameters use question marks. The connector also accepts named parameters as described in the cursor reference.

DB-API type objects such as STRING, BINARY, NUMBER, DATETIME and ROWID are unavailable. The type_code entry in Cursor.description is always None.

Value constructors

Function Returns
Date(year, month, day) A datetime.date.
Time(hour, minute, second) A datetime.time.
Timestamp(year, month, day, hour, minute, second) A naive datetime.datetime.
DateFromTicks(ticks) The local date for Unix epoch seconds.
TimeFromTicks(ticks) The local time for Unix epoch seconds.
TimestampFromTicks(ticks) A naive local timestamp for Unix epoch seconds.
Binary(string) The UTF-8 bytes of a Python string. Pass existing bytes directly as a query parameter.

The tick constructors use the process’s local timezone and return values at whole-second resolution. See the type conversion reference for timestamp precision and result types.

from time import localtime

import polypheny

assert polypheny.Date(2026, 4, 15).isoformat() == "2026-04-15"
assert polypheny.Time(9, 30, 0).isoformat() == "09:30:00"
assert polypheny.Timestamp(2026, 4, 15, 9, 30, 0).isoformat() == "2026-04-15T09:30:00"
assert polypheny.Binary("apple") == b"apple"

local_epoch = localtime(0)
assert polypheny.DateFromTicks(0) == polypheny.Date(*local_epoch[:3])
assert polypheny.TimeFromTicks(0) == polypheny.Time(*local_epoch[3:6])
assert polypheny.TimestampFromTicks(0) == polypheny.Timestamp(*local_epoch[:6])
© Polypheny GmbH. All Rights Reserved.