7.5.2 Import Datastore
Use the OML4Py import datastore feature to restore saved Python or OML proxy objects into your current database instance.
After exporting a datastore from one Oracle AI Database instance, you can use
the oml.import_ds API to import it into another instance. This process
lets you migrate Python and OML proxy objects—including datasets, models, and other
analytical assets—and make them available in your new instance.
Use the oml.import_ds function to restore these objects
from a zip archive into your current database instance.
oml.import_ds(
file_name,
grantable=None,
overwrite=False,
append=False,
database_directory="DATA_PUMP_DIR"
)
-
file_name (str): Specifies the name and location of the zip file containing the datastores to import.
-
grantable (bool, optional): If set to
True, allows the imported datastores to have their read privilege granted to other users. This is ignored ifoverwriteorappendis used. -
overwrite (bool, optional): If set to
True, overwrites any existing datastores with the same name. -
append (bool, optional): If set to
True, appends the imported Python objects to existing datastores with the same name. -
database_directory (str, optional, default=
'DATA_PUMP_DIR'): Specify an existing database directory where you have read and write privileges to transfer the datastore from the zip file into the database.
Example 7-22 Import a Datastore
Import a datastore, ds1.zip, into your current database environment using the OML4Py
oml.import_ds API. Specify the file name of the datastore
archive to restore the Python or OML proxy objects it contains. After the import,
you can view the available datastores and load the objects for immediate use.
# Import datastores from a zip file located in the database directory
oml.import_ds(file_name="ds1.zip")
# List available datastores and see object counts
print(oml.ds.dir()[['datastore_name', 'object_count']])
# Load the imported objects from a specific datastore
loaded_objects = oml.ds.load(name="ds_pyobjs1")
print(sorted(loaded_objects))Parent topic: Import and Export Datastore