Python Client
Python DBAPI API
Opteryx can be embedded into Python applications, scripts, and notebooks. It supports a subset of the Python DBAPI (PEP 249) interface.
Usage
import opteryx
# Establish a connection
conn = opteryx.connect()
# Create a cursor object
cursor = conn.cursor()
# Execute a SQL query
cursor.execute("SELECT * FROM $planets;")
# Fetch all rows
rows = cursor.fetchall()
Query Results
Query results can be accessed through the Cursor, which is an Orso DataFrame. You can retrieve data in several ways:
- Iterating through the Cursor
- Using
fetchone(),fetchmany(), andfetchall()methods - Format conversion routines:
arrow()returns an Arrow Tablepandas()returns a pandas DataFramepolars()returns a Polars DataFrame
Short Form API
Opteryx also provides a simplified, short-form, API that assumes default values for creating the Connection and Cursor objects.