6.4.1 About OML4Py Datastores

In an OML4Py datastore, you can store Python objects, which you can then use in subsequent Python sessions; you can also make them available to other users or programs.

Python objects, including OML4Py proxy objects, exist only for the duration of the current Python session unless you explicitly save them. You can save a Python object, including oml proxy objects, to a named datastore and then load that object in a later Python session, including an Embedded Python Execution session. OML4Py creates the datastore in the user’s database schema. A datastore, and the objects it contains, persist in the database until you delete them.

You can grant or revoke read privilege permission to another user to a datastore that you created or to objects in a datastore.

OML4Py has Python functions for managing objects in a datastore. It also has PL/SQL procedures for granting or revoking the read privilege and database views for listing available datastores and their contents.

Using a datastore, you can do the following:

  • Save OML4Py and other Python objects that you create in one Python session and load them in another Python session.

  • Pass arguments to Python functions for use in Embedded Python Execution.

  • Pass objects for use in Embedded Python Execution. You could, for example, use the oml.glm class to build an Oracle Machine Learning model and save it in a datastore. You could then use that model to score data in the database through Embedded Python Execution.

Python Interface for Datastores

The following table lists the Python functions for saving and managing objects in a datastore.

Function Description
oml.ds.delete

Deletes one or more datastores or Python objects from a datastore.

oml.ds.dir

Lists the datastores available to the current user.

oml.ds.load

Loads Python objects from a datastore into the user’s session.

oml.ds.save

Saves Python objects to a named datastore in the user’s database schema.

The following table lists the Python functions for managing access to datastores and datastore objects.

Function Description
oml.grant

Grants read privilege permission to another user to a datastore or a user-defined Python function in the script repository owned by the current user.

oml.revoke

Revokes the read privilege permission that was granted to another user to a datastore or a user-defined Python function in the script repository owned by the current user.