13. API: DbObjectType Objects
13.1. DbObjectType Class
- class oracledb.DbObjectType
A DbObjectType object is returned with
This object is an extension to the DB API definition.Connection.gettype()call and is available as theVar.typefor variables containing Oracle Database objects.
13.1.1. DbObjectType Methods
- DbObjectType.__call__(value: Sequence | None = None) DbObject
The object type may be called directly and serves as an alternative way of calling
newobject().
- DbObjectType.newobject(value: Sequence | None = None) DbObject
Returns a new Oracle object of the given type. This object can then be modified by setting its attributes and then bound to a cursor for interaction with Oracle. If the object type refers to a collection, a sequence may be passed and the collection will be initialized with the items in that sequence.
13.1.2. DbObjectType Attributes
- property DbObjectType.attributes: list[DbObjectAttr]
This read-only attribute returns a list of the attributes that make up the object type.
- property DbObjectType.element_type: DbObjectType | DbType
This read-only attribute returns the type of elements found in collections of this type, if iscollection is True; otherwise, it returns None. If the collection contains objects, this will be another object type; otherwise, it will be one of the database type constants.
- property DbObjectType.iscollection: bool
This read-only attribute returns a boolean indicating if the object type refers to a collection or not.
- property DbObjectType.name: str
This read-only attribute returns the name of the type.
- property DbObjectType.package_name: str
This read-only attribute returns the name of the package containing the PL/SQL type or None if the type is not a PL/SQL type.
- property DbObjectType.schema: str
This read-only attribute returns the name of the schema that owns the type.
13.2. DbObject Class
- class oracledb.DbObject
A DbObject object is returned by the
This object is an extension to the DB API definition.DbObjectType.newobject()call and can be bound to variables of typeDB_TYPE_OBJECT. Attributes can be retrieved and set directly.
13.2.1. DbObject Methods
- DbObject.append(element: Any) None
Appends an element to the collection object. If no elements exist in the collection, this creates an element at index 0; otherwise, it creates an element immediately following the highest index available in the collection.
- DbObject.asdict() dict
Returns a dictionary where the collection’s indexes are the keys and the elements are its values.
- DbObject.aslist() list
Returns a list of each of the collection’s elements in index order.
- DbObject.delete(index: int) None
Delete the element at the specified index of the collection. If the element does not exist or is otherwise invalid, an error is raised. Note that the indices of the remaining elements in the collection are not changed. In other words, the delete operation creates holes in the collection.
- DbObject.exists(index: int) bool
Return True or False indicating if an element exists in the collection at the specified index.
- DbObject.extend(seq: list) None
Appends all of the elements in the sequence to the collection. This is the equivalent of performing append() for each element found in the sequence.
- DbObject.first() int
Returns the index of the first element in the collection. If the collection is empty, None is returned.
- DbObject.getelement(index: int) Any
Returns the element at the specified index of the collection. If no element exists at that index, an exception is raised.
- DbObject.last() int
Returns the index of the last element in the collection. If the collection is empty, None is returned.
- DbObject.next(index: int) int
Returns the index of the next element in the collection following the specified index. If there are no elements in the collection following the specified index, None is returned.
- DbObject.prev(index: int) int
Returns the index of the element in the collection preceding the specified index. If there are no elements in the collection preceding the specified index, None is returned.
- DbObject.setelement(index: int, value: Any) None
Sets the value in the collection at the specified index to the given value.
- DbObject.size() int
Returns the number of elements in the collection.
- DbObject.trim(num: int) None
Removes the specified number of elements from the end of the collection.
13.2.2. DbObject Attributes
- property DbObject.type: DbObjectType
This read-only attribute arturns an ObjectType corresponding to the type of the object.
13.3. DbObjectAttribute Class
- class oracledb.DbObjectAttr
The elements of
This object is an extension to the DB API definition.DbObjectType.attributesare instances of this type.
13.3.1. DbObjectAttr Attributes
- property DbObjectAttr.max_size: int | None
This read-only attribute returns the maximum size (in bytes) of the attribute when the attribute’s type is one of DB_TYPE_RAW, DB_TYPE_CHAR, DB_TYPE_NCHAR, DB_TYPE_VARCHAR and DB_TYPE_NVARCHAR. For all other types, the value returned is None.
Added in version 3.0.0.
- property DbObjectAttr.name: str
This read-only attribute returns the name of the attribute.
- property DbObjectAttr.precision: int | None
This read-only attribute returns the precision of the attribute when the attribute’s type is DB_TYPE_NUMBER. For all other types, the value returned is None.
Added in version 3.0.0.
- property DbObjectAttr.scale: int | None
This read-only attribute returns the scale of the attribute when the attribute’s type is DB_TYPE_NUMBER. For all other types, the value returned is None.
Added in version 3.0.0.
- property DbObjectAttr.type: DbObjectType | DbType
This read-only attribute returns the type of the attribute. This will be an Oracle Object Type if the variable binds Oracle objects; otherwise, it will be one of the database type constants.