Skip to content

YAQL API Reference

yaql

YAQL - YAML Advanced Query Language

YAQL provides a standard SQL query interface for YAML data. YAQL dynamically loads YAML data into an in-memory SQLite database, allowing users to execute SQL queries against the data. YAQL generated database schemas are derived from YASL schema definitions, ensuring data integrity and consistency.

export_data(export_path, min_mode=False)

Exports the data from the global YAQL engine to YAML files.

Parameters:

Name Type Description Default
export_path str

Directory where the YAML files will be written.

required
min_mode bool

If True, writes all records of a type to a single file separated by '---'.

False

Returns:

Type Description
int

Number of files written.

Source code in src/yaql/engine.py
649
650
651
652
653
654
655
656
657
658
659
660
def export_data(export_path: str, min_mode: bool = False) -> int:
    """
    Exports the data from the global YAQL engine to YAML files.

    Args:
        export_path: Directory where the YAML files will be written.
        min_mode: If True, writes all records of a type to a single file separated by '---'.

    Returns:
        Number of files written.
    """
    return _yaql_engine.export_data(export_path, min_mode=min_mode)

get_session()

Get a new SQLModel Session bound to the global YAQL engine.

Returns:

Type Description
Session

A new Session object for interacting with the database.

Source code in src/yaql/engine.py
663
664
665
666
667
668
669
670
def get_session() -> Session:
    """
    Get a new SQLModel Session bound to the global YAQL engine.

    Returns:
        A new Session object for interacting with the database.
    """
    return _yaql_engine.session

load_data(data_path)

Load YAML data files into the global YAQL engine.

Parameters:

Name Type Description Default
data_path str

Path to a .yaml/.yml file or a directory containing such files.

required

Returns:

Type Description
int

The number of data records successfully loaded.

Source code in src/yaql/engine.py
636
637
638
639
640
641
642
643
644
645
646
def load_data(data_path: str) -> int:
    """
    Load YAML data files into the global YAQL engine.

    Args:
        data_path: Path to a .yaml/.yml file or a directory containing such files.

    Returns:
        The number of data records successfully loaded.
    """
    return _yaql_engine.load_data(data_path)

load_schema(schema_path)

Load YASL schema definitions into the global YAQL engine.

Parameters:

Name Type Description Default
schema_path str

Path to a .yasl file or a directory containing .yasl files.

required

Returns:

Type Description
bool

True if all schemas were loaded successfully, False otherwise.

Source code in src/yaql/engine.py
623
624
625
626
627
628
629
630
631
632
633
def load_schema(schema_path: str) -> bool:
    """
    Load YASL schema definitions into the global YAQL engine.

    Args:
        schema_path: Path to a .yasl file or a directory containing .yasl files.

    Returns:
        True if all schemas were loaded successfully, False otherwise.
    """
    return _yaql_engine.load_schema(schema_path)