pyaccesskit.schema.expressions¶
pyaccesskit.schema.expressions ¶
Access expression literals: rendering Python values and parsing them back.
Access stores properties such as DefaultValue as expression text. A classic mistake is setting a text
default to Unknown instead of "Unknown" (Access then looks for a field or function called Unknown).
PyAccessKit takes Python values and renders the right literal; raw expressions are passed with
:class:Expr::
Column.text("Status", default="Unknown") # stored as "Unknown"
Column.date_time("CreatedAt", default=Expr("Now()"))
Column.currency("Total", default=0) # stored as 0
DefaultValue
module-attribute
¶
DefaultValue = (
Expr
| bool
| int
| float
| Decimal
| datetime
| date
| time
| str
)
Types accepted as a column default: a Python literal or an :class:Expr.
Expr
dataclass
¶
Expr(expr: str)
A raw Access expression, passed through verbatim (e.g. Expr("Now()"), Expr("[Qty]*2")).
render_literal ¶
render_literal(value: DefaultValue) -> str
Render a Python value as Access expression text.
Raises:
| Type | Description |
|---|---|
SpecError
|
For values Access cannot represent (NaN, time-zone aware datetimes...). |
parse_literal ¶
parse_literal(text: str | None) -> DefaultValue | None
Parse Access expression text into a Python literal, or an :class:Expr if it is not a literal.
Returns None for empty text. Understands quoted strings, numbers, True/False/Yes/No/
On/Off and #date# literals (ISO or US m/d/yyyy order).