Utilities API Reference

Logging

class surrealengine.logging.SurrealEngineLogger(name='surrealengine', level=20)[source]

Bases: object

Logger for SurrealEngine.

This class provides a centralized logging system for SurrealEngine, with support for different log levels and configurable handlers.

logger

The underlying logger instance

__init__(name='surrealengine', level=20)[source]

Initialize a SurrealEngineLogger.

Parameters:
  • name (str) – The name of the logger

  • level (int) – The log level to use

set_level(level)[source]

Set the log level.

Parameters:

level (int) – The log level to use

add_file_handler(filename, level=None)[source]

Add a file handler to the logger.

Parameters:
  • filename (str) – The name of the log file

  • level (int | None) – The log level for the file handler (defaults to logger level)

debug(msg, *args, **kwargs)[source]

Log a debug message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

info(msg, *args, **kwargs)[source]

Log an info message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

warning(msg, *args, **kwargs)[source]

Log a warning message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

error(msg, *args, **kwargs)[source]

Log an error message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

critical(msg, *args, **kwargs)[source]

Log a critical message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

exception(msg, *args, **kwargs)[source]

Log an exception message.

Parameters:
  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

log(level, msg, *args, **kwargs)[source]

Log a message at the specified level.

Parameters:
  • level (int) – The log level to use

  • msg (str) – The message to log

  • *args – Additional arguments to pass to the logger

  • **kwargs – Additional keyword arguments to pass to the logger

DataGrid API

DataGrid Query Helpers for SurrealEngine - Efficient database querying for grid data

class surrealengine.datagrid_api.DataGridQueryBuilder(document_class)[source]

Bases: object

Build efficient SurrealDB queries for DataGrid endpoints

__init__(document_class)[source]
apply_filters(filters)[source]

Apply field filters to the queryset

Parameters:

filters (Dict[str, Any]) – Dictionary of field->value filters

Apply text search across multiple fields using contains operator

Parameters:
  • search (str) – Search term

  • search_fields (List[str]) – List of fields to search in

apply_sorting(sort_field=None, sort_order='asc')[source]

Apply sorting to the queryset

Parameters:
  • sort_field (str | None) – Field to sort by

  • sort_order (str) – ‘asc’ or ‘desc’

async get_paginated_data(offset, limit)[source]

Get paginated data with total count

Parameters:
  • offset (int) – Number of records to skip

  • limit (int) – Number of records to return

Returns:

Tuple of (total_count, paginated_results)

get_paginated_data_sync(offset, limit)[source]

Synchronous version of get_paginated_data

async surrealengine.datagrid_api.get_grid_data(document_class, request_args, search_fields, custom_filters=None, default_sort=None)[source]

Get paginated grid data using efficient SurrealDB queries

Parameters:
  • document_class – SurrealEngine document class

  • request_args (Dict[str, Any]) – Request parameters (limit, offset, search, etc.)

  • search_fields (List[str]) – List of fields to search in

  • custom_filters (Dict[str, str] | None) – Custom field filters from request

  • default_sort (str | None) – Default sorting field

Returns:

total, “rows”: rows} for BootstrapTable format

Return type:

{“total”

surrealengine.datagrid_api.get_grid_data_sync(document_class, request_args, search_fields, custom_filters=None, default_sort=None)[source]

Synchronous version of get_grid_data

surrealengine.datagrid_api.parse_datatables_params(request_args)[source]

Convert DataTables parameters to standard offset/limit format

surrealengine.datagrid_api.format_datatables_response(total, rows, draw)[source]

Format response for DataTables