The polypheny
module provides the entry point for interacting with a Polypheny instance. It only exposes the connect()
function, which establishes a connection to the database. This page details how to use connect()
, the supported transport types, and best practices for handling connections.
polypheny.connect(address=None, *, username=None, password=None, transport=None, **kwargs)
The connect()
function establishes a connection to a Polypheny database instance. It returns a Connection
object, which can be used to create cursors, execute queries, and manage transactions.
Parameters:
address
(tuple[str, int]
|str
, optional):- A Unix socket path for
unix
transport or a(hostname, port)
tuple forplain
transport. - Defaults to
~/.polypheny/polypheny-prism.sock
if not provided.
- A Unix socket path for
username
(str
, optional):- The username for authentication.
password
(str
, optional):- The password for authentication.
transport
(str
, optional):- Specifies the transport type, either
plain
orunix
. Defaults tounix
.
- Specifies the transport type, either
Returns:
Connection
: An activeConnection
object to interact with the database.
Example:
from polypheny import connect
# Connecting with plain transport
connection = connect(address=('localhost', 20591), username='admin', password='admin', transport='plain')
# Connecting with unix transport (default)
connection = connect()
Transport Options
Polypheny supports multiple transport methods for communication between the Python driver and the database.
plain
Transport
- Uses a standard TCP/IP connection.
- Requires specifying a hostname and port.
- Recommended for remote connections.
Example:
conn = connect(address=('localhost', 20591), username='admin', password='admin', transport='plain')
unix
Transport
- Uses a Unix socket for inter-process communication.
- Does not require specifying a hostname or port.
- Recommended for local development.
Example:
conn = connect()
© Polypheny GmbH. All Rights Reserved.