7.5.1 Export Datastore

Use the OML4Py export datastore feature to save Python or OML proxy objects from your current database instance into a zip archive.

Use the oml.export_ds API to export a datastore from your current Oracle AI Database instance to a zip archive. This allows you to migrate Python and OML proxy objects—including datasets, models, and other analytical assets—from your instance, so you can later import them into another instance as needed.

Use the oml.export_ds function to save these objects to a portable zip archive.

oml.export_ds(
    file_name,
    name=None,
    regex_match=False,
    overwrite=False,
    database_directory="DATA_PUMP_DIR"
)
Parameters:
  • file_name (str): Specifies the name of the destination zip file for the exported datastores.

  • name (str, list of str, or None): Specifies the name(s) of the datastores to export, or a regular expression to match datastore names. If name is None or an empty list, all datastores are exported. Only database objects owned by the current user in the named datastores are included.

  • regex_match (bool, default=False): If set to True, treats the name argument as a regular expression for matching datastore names.

  • overwrite (bool, default=False): If True, overwrites the zip archive if it already exists.
  • database_directory (str, default='DATA_PUMP_DIR'): Specifies the name of an existing database directory where you have read and write privileges, used to export the datastore contents to a zip archive.

Example 7-21 Export a Datastore

The following example shows how to save Python objects into OML4Py datastores and then export them to a zip archive.

import oml
from sklearn import datasets

# Save Python objects into datastores
iris = datasets.load_iris()
diabetes = datasets.load_diabetes()
oml.ds.save(objs={'iris': iris}, name="ds_pyobjs1", description="python datasets")
oml.ds.save(objs={'diabetes': diabetes}, name="ds_pyobjs2", description="python datasets")

# Export datastores to a zip file
oml.export_ds(file_name="ds1.zip", name='pyobjs', regex_match=True, overwrite=True)

# Optionally delete original datastores
oml.ds.delete(name=["ds_pyobjs1", "ds_pyobjs2"])