Skip to content

incendium.db.get_data

César Román edited this page Apr 30, 2024 · 19 revisions

Description

Get data by executing a stored procedure.

Syntax

incendium.db.get_data(stored_procedure, [database], [params])

Args:

  • stored_procedure (str): The name of the stored procedure to call.
  • database (str): The name of the database connection to execute against. If omitted or "", the project's default database connection will be used. Optional.
  • params (list[InParam]): A list containing all INPUT parameters as InParam objects. Optional.

Returns:

  • Dataset: A Dataset that is the resulting data of the stored procedure call, if any.

Recommendations

None.

Code Examples

Passing parameters.

from __future__ import print_function

import system.db
from incendium import db
from incendium.db import InParam
from java.lang import Exception as JavaException


def get(int_param):
    """Get a row from the database."""
    data = None

    try:
        params = [InParam("int_param", system.db.INTEGER, int_param)]
        data = db.get_data("schema.stored_procedure", params=params)
    except JavaException as exc:
        # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(exc))
    else:
        return data

Passing no parameters.

from __future__ import print_function

from incendium import db
from java.lang import Exception as JavaException


def get_all():
    """Get multiple rows of data from the database."""
    data = None

    try:
        data = db.get_data("schema.stored_procedure")
    except JavaException as exc:
        # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(exc))

    return data
Clone this wiki locally