Rows.__getattr__()#

relationalai
#Rows.__getattr__(name: str) -> Expression

Gets an Expression object representing a column in the Rows object by its key using dot notation. Only works if the Rows object was created with as_rows() from a list of dictionaries.

Parameters#

NameTypeDescription
namestrThe string key of the column to get from the Rows object.

Returns#

An Expression object.

Example#

Rows.__getattr__() allows you to access columns in a Rows object by their string key using dot notation:

#import relationalai as rai
from relationalai.std import as_rows


# =====
# SETUP
# =====

model = rai.Model("MyModel")
Person = model.Type("Person")


# =======
# EXAMPLE
# =======

# Define Person objects from a list of dictionaries.
with model.rule():
    row = as_rows([
        {"id": 1, "name": "Alice", "age": 30},
        {"id": 2, "name": "Bob", "age": 45},
    ])
    Person.add(id=row.id).set(name=row.name, age=row.age)  # Access by key name

See Also#