mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-05 16:03:47 +00:00
An empty role list meant "nothing to pick" whether the endpoint said so or never answered, so a failed lookup on a permissioned data table let an app be created naming it with no role — the case the check exists for. The failure is carried, and an app that would name the data table waits for an answer. The fork dialog said "Keep original" on the same failure, for a data table the backend drops from the fork when its permissions are on: it says the check did not answer instead of asserting the outcome. The generated Python signature keeps the bare `*`. `datatable(name, *, role)` is keyword-only, and an agent following the advertised positional form gets a TypeError. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S5arH3G2Sa1Qqm32veJQ1n
76 lines
2.0 KiB
Markdown
76 lines
2.0 KiB
Markdown
## Python Datatable API (wmill)
|
|
|
|
Import: `import wmill`
|
|
|
|
# Get a DataTable client for SQL queries.
|
|
#
|
|
# Args:
|
|
# name: Database name (default: "main")
|
|
# role: DataTable role to run as, on a datatable with permissions
|
|
# enabled (default: the data table's default role)
|
|
#
|
|
# Returns:
|
|
# DataTableClient instance
|
|
#
|
|
# Example:
|
|
# wmill.datatable("main", role="operator")
|
|
def datatable(name: str = 'main', *, role: Optional[str] = None) -> DataTableClient
|
|
|
|
# Client for executing SQL queries against Windmill DataTables.
|
|
class DataTableClient:
|
|
# Initialize DataTableClient.
|
|
#
|
|
# Args:
|
|
# client: Windmill client instance
|
|
# name: DataTable name
|
|
# role: DataTable role to run as, on a datatable with permissions
|
|
# enabled (default: the data table's default role)
|
|
def __init__(client: Windmill, name: str, role: Optional[str] = None)
|
|
|
|
# Execute a SQL query against the DataTable.
|
|
#
|
|
# Args:
|
|
# sql: SQL query string with $1, $2, etc. placeholders
|
|
# *args: Positional arguments to bind to query placeholders
|
|
#
|
|
# Returns:
|
|
# SqlQuery instance for fetching results
|
|
def query(sql: str, *args) -> SqlQuery
|
|
|
|
|
|
# Query result handler for DataTable and DuckLake queries.
|
|
class SqlQuery:
|
|
# Initialize SqlQuery.
|
|
#
|
|
# Args:
|
|
# sql: SQL query string
|
|
# fetch_fn: Function to execute the query
|
|
def __init__(sql: str, fetch_fn)
|
|
|
|
# Execute query and fetch results.
|
|
#
|
|
# Args:
|
|
# result_collection: Optional result collection mode
|
|
#
|
|
# Returns:
|
|
# Query results
|
|
def fetch(result_collection: str | None = None)
|
|
|
|
# Execute query and fetch first row of results.
|
|
#
|
|
# Returns:
|
|
# First row of query results
|
|
def fetch_one()
|
|
|
|
# Execute query and fetch first row of results. Return result as a scalar value.
|
|
#
|
|
# Returns:
|
|
# First row of query result as a scalar value
|
|
def fetch_one_scalar()
|
|
|
|
# Execute query and don't return any results.
|
|
#
|
|
def execute()
|
|
|
|
|