Skip to content

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(), and fetchall() methods
  • Format conversion routines:

Short Form API

Opteryx also provides a simplified, short-form, API that assumes default values for creating the Connection and Cursor objects.

Usage

import opteryx

# Execute a SQL query and get a cursor
cursor = opteryx.query("SELECT * FROM $planets;")

# Fetch all rows
rows = cursor.fetchall()