Skip to content

incendium.db.get_data

César Román edited this page Oct 15, 2021 · 19 revisions

Description

Get data by executing a stored procedure.

Syntax

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 (dict): A Dictionary containing all parameters. 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

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


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

    try:
        params = {"int_param": [system.db.INTEGER, int_param]}
        data = db.get_data("schema.stored_procedure", params)
    except JException as e:  # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(e))
    finally:
        return data

Passing no parameters.

from __future__ import print_function

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


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

    try:
        data = db.get_data("schema.stored_procedure")
    except JException as e:  # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(e))
    finally:
        return data
Clone this wiki locally