6.3.1 About Moving Data Between the Database and a Python Session

Using the functions described in this topic, you can move data between the your local Python session and an Oracle database schema.

The following functions create proxy oml Python objects from database objects, create database tables from Python objects, list the objects in the workspace, and drop tables and views.

Function Definition
oml.create

Creates a persistent database table from a Python data set.

oml.cursor Returns a cx_Oracle cursor object for the current OML4Py database connection.
oml.dir

Returns the names of the oml objects in the workspace.

oml.drop

Drops a persistent database table or view.

oml_object.pull

Creates a local Python object that contains a copy of the database data referenced by the oml object.

oml.push

Pushes data from the OML Notebooks Python session memory into a temporary table in the database.

oml.sync

Creates an oml.DataFrame proxy object in Python that represents a database table, view, or query.

With the oml.push function, you can create a temporary database table, and its corresponding proxy oml.DataFrame object, from a Python object in your local Python session. The temporary table is automatically deleted when the OML Notebook or OML4Py client connection to the database ends unless you have saved its proxy object to a datastore before disconnecting.

With the pull method of an oml object, you can create a local Python object that contains a copy of the database data represented by an oml proxy object.

The oml.push function implicitly coerces Python data types to oml data types and the pull method on oml objects coerces oml data types to Python data types.

With the oml.create function, you can create a persistent database table and a corresponding oml.DataFrame proxy object from a Python data set.

With the oml.sync function, you can synchronize the metadata of a database table or view with the oml object representing the database object.

With the oml.cursor function, you can create a cx_Oracle cursor object for the current database connection. You can user the cursor to run queries against the database, as shown in Example 6-13.