Database API

class tango.Database

Database is the high level Tango object which contains the link to the static database. Database provides methods for all database commands : get_device_property(), put_device_property(), info(), etc.. To create a Database, use the default constructor. Example:

db = Database()

The constructor uses the TANGO_HOST env. variable to determine which instance of the Database to connect to.

add_server(self, servname, dev_info, with_dserver=False) → None

Add a (group of) devices to the database. This is considered as a low level call because it may render the database inconsistent if it is not used properly.

If with_dserver parameter is set to False (default), this call will only register the given dev_info(s). You should include in the list of dev_info an entry to the usually hidden DServer device.

If with_dserver parameter is set to True, the call will add an additional DServer device if it is not included in the dev_info parameter.

Example using with_dserver=True:

dev_info1 = DbDevInfo()
dev_info1.name = 'my/own/device'
dev_info1._class = 'MyDevice'
dev_info1.server = 'MyServer/test'
db.add_server(dev_info1.server, dev_info, with_dserver=True)

Same example using with_dserver=False:

dev_info1 = DbDevInfo()
dev_info1.name = 'my/own/device'
dev_info1._class = 'MyDevice'
dev_info1.server = 'MyServer/test'

dev_info2 = DbDevInfo()
dev_info1.name = 'dserver/' + dev_info1.server
dev_info1._class = 'DServer
dev_info1.server = dev_info1.server

dev_info = dev_info1, dev_info2
db.add_server(dev_info1.server, dev_info)

New in version 8.1.7: added with_dserver parameter

Parameters:
servname:(str) server name
dev_info:(sequence<DbDevInfo> | DbDevInfos | DbDevInfo) containing the server device(s) information
with_dserver:(bool) whether or not to auto create DServer device in server
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

delete_class_attribute_property(self, class_name, value) → None
Delete a list of attribute properties for the specified class.
Parameters:
class_name:

(str) class name

propnames:

can be one of the following:

  1. DbData [in] - several property data to be deleted
  2. sequence<str> [in]- several property data to be deleted
  3. sequence<DbDatum> [in] - several property data to be deleted
  4. dict<str, seq<str>> keys are attribute names and value being a list of attribute property names
Return:

None

Throws:

ConnectionFailed, CommunicationFailed DevFailed from device (DB_SQLError)

delete_class_property(self, class_name, value) → None
Delete a the given of properties for the specified class.
Parameters:
class_name:

(str) class name

value:

can be one of the following:

  1. str [in] - single property data to be deleted
  2. DbDatum [in] - single property data to be deleted
  3. DbData [in] - several property data to be deleted
  4. sequence<str> [in]- several property data to be deleted
  5. sequence<DbDatum> [in] - several property data to be deleted
  6. dict<str, obj> [in] - keys are property names to be deleted (values are ignored)
  7. dict<str, DbDatum> [in] - several DbDatum.name are property names to be deleted (keys are ignored)
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

delete_device_attribute_property(self, dev_name, value) → None
Delete a list of attribute properties for the specified device.
Parameters:
devname:(string) device name
propnames:can be one of the following: 1. DbData [in] - several property data to be deleted 2. sequence<str> [in]- several property data to be deleted 3. sequence<DbDatum> [in] - several property data to be deleted 3. dict<str, seq<str>> keys are attribute names and value being a list of attribute property names
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

delete_device_property(self, dev_name, value) → None

Delete a the given of properties for the specified device.

Parameters:
dev_name:(str) object name
value:can be one of the following: 1. str [in] - single property data to be deleted 2. DbDatum [in] - single property data to be deleted 3. DbData [in] - several property data to be deleted 4. sequence<str> [in]- several property data to be deleted 5. sequence<DbDatum> [in] - several property data to be deleted 6. dict<str, obj> [in] - keys are property names to be deleted (values are ignored) 7. dict<str, DbDatum> [in] - several DbDatum.name are property names to be deleted (keys are ignored)
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

delete_property(self, obj_name, value) → None
Delete a the given of properties for the specified object.
Parameters:
obj_name:

(str) object name

value:

can be one of the following:

  1. str [in] - single property data to be deleted
  2. DbDatum [in] - single property data to be deleted
  3. DbData [in] - several property data to be deleted
  4. sequence<string> [in]- several property data to be deleted
  5. sequence<DbDatum> [in] - several property data to be deleted
  6. dict<str, obj> [in] - keys are property names to be deleted (values are ignored)
  7. dict<str, DbDatum> [in] - several DbDatum.name are property names to be deleted (keys are ignored)
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

export_server(self, dev_info) → None
Export a group of devices to the database.
Parameters:
devinfo:(sequence<DbDevExportInfo> | DbDevExportInfos | DbDevExportInfo) containing the device(s) to export information
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_class_attribute_property(self, class_name, value) → dict<str, dict<str, seq<str>>
Query the database for a list of class attribute properties for the specified class. The method returns all the properties for the specified attributes.
Parameters:
class_name:

(str) class name

propnames:

can be one of the following:

  1. str [in] - single attribute properties to be fetched
  2. DbDatum [in] - single attribute properties to be fetched
  3. DbData [in,out] - several attribute properties to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several attribute properties to be fetched
  5. sequence<DbDatum> [in] - several attribute properties to be fetched
  6. dict<str, obj> [in,out] - keys are attribute names In this case the given dict values will be changed to contain the several attribute property values
Return:

a dictionary which keys are the attribute names the value associated with each key being a another dictionary where keys are property names and value is a sequence of strings being the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_class_property(self, class_name, value) → dict<str, seq<str>>
Query the database for a list of class properties.
Parameters:
class_name:

(str) class name

value:

can be one of the following:

  1. str [in] - single property data to be fetched
  2. tango.DbDatum [in] - single property data to be fetched
  3. tango.DbData [in,out] - several property data to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several property data to be fetched
  5. sequence<DbDatum> [in] - several property data to be fetched
  6. dict<str, obj> [in,out] - keys are property names In this case the given dict values will be changed to contain the several property values
Return:

a dictionary which keys are the property names the value associated with each key being a a sequence of strings being the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_device_attribute_property(self, dev_name, value) → dict<str, dict<str, seq<str>>>
Query the database for a list of device attribute properties for the specified device. The method returns all the properties for the specified attributes.
Parameters:
dev_name:

(string) device name

value:

can be one of the following:

  1. str [in] - single attribute properties to be fetched
  2. DbDatum [in] - single attribute properties to be fetched
  3. DbData [in,out] - several attribute properties to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several attribute properties to be fetched
  5. sequence<DbDatum> [in] - several attribute properties to be fetched
  6. dict<str, obj> [in,out] - keys are attribute names In this case the given dict values will be changed to contain the several attribute property values
Return:

a dictionary which keys are the attribute names the value associated with each key being a another dictionary where keys are property names and value is a DbDatum containing the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_device_property(self, dev_name, value) → dict<str, seq<str>>

Query the database for a list of device properties.

Parameters:
dev_name:

(str) object name

value:

can be one of the following:

  1. str [in] - single property data to be fetched
  2. DbDatum [in] - single property data to be fetched
  3. DbData [in,out] - several property data to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several property data to be fetched
  5. sequence<DbDatum> [in] - several property data to be fetched
  6. dict<str, obj> [in,out] - keys are property names In this case the given dict values will be changed to contain the several property values
Return:

a dictionary which keys are the property names the value associated with each key being a a sequence of strings being the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_device_property_list(self, dev_name, wildcard, array=None) → DbData
Query the database for a list of properties defined for the specified device and which match the specified wildcard. If array parameter is given, it must be an object implementing de ‘append’ method. If given, it is filled with the matching property names. If not given the method returns a new DbDatum containing the matching property names.

New in PyTango 7.0.0

Parameters:
dev_name:(str) device name
wildcard:(str) property name wildcard
array:[out] (sequence) (optional) array that will contain the matching property names.
Return:

if container is None, return is a new DbDatum containing the matching property names. Otherwise returns the given array filled with the property names

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

get_property(self, obj_name, value) → dict<str, seq<str>>
Query the database for a list of object (i.e non-device) properties.
Parameters:
obj_name:

(str) object name

value:

can be one of the following:

  1. str [in] - single property data to be fetched
  2. DbDatum [in] - single property data to be fetched
  3. DbData [in,out] - several property data to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several property data to be fetched
  5. sequence<DbDatum> [in] - several property data to be fetched
  6. dict<str, obj> [in,out] - keys are property names In this case the given dict values will be changed to contain the several property values
Return:

a dictionary which keys are the property names the value associated with each key being a a sequence of strings being the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

get_property_forced(obj_name, value)

get_property(self, obj_name, value) -> dict<str, seq<str>>

Query the database for a list of object (i.e non-device) properties.
Parameters:
obj_name:

(str) object name

value:

can be one of the following:

  1. str [in] - single property data to be fetched
  2. DbDatum [in] - single property data to be fetched
  3. DbData [in,out] - several property data to be fetched In this case (direct C++ API) the DbData will be filled with the property values
  4. sequence<str> [in] - several property data to be fetched
  5. sequence<DbDatum> [in] - several property data to be fetched
  6. dict<str, obj> [in,out] - keys are property names In this case the given dict values will be changed to contain the several property values
Return:

a dictionary which keys are the property names the value associated with each key being a a sequence of strings being the property value.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

put_class_attribute_property(self, class_name, value) → None
Insert or update a list of properties for the specified class.
Parameters:
class_name:

(str) class name

propdata:

can be one of the following:

  1. tango.DbData - several property data to be inserted

  2. sequence<DbDatum> - several property data to be inserted

  3. dict<str, dict<str, obj>> keys are attribute names and value being another dictionary which keys are the attribute property names and the value associated with each key being:

    3.1 seq<str> 3.2 tango.DbDatum

Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

put_class_property(self, class_name, value) → None
Insert or update a list of properties for the specified class.
Parameters:
class_name:(str) class name
value:can be one of the following: 1. DbDatum - single property data to be inserted 2. DbData - several property data to be inserted 3. sequence<DbDatum> - several property data to be inserted 4. dict<str, DbDatum> - keys are property names and value has data to be inserted 5. dict<str, obj> - keys are property names and str(obj) is property value 6. dict<str, seq<str>> - keys are property names and value has data to be inserted
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

put_device_attribute_property(self, dev_name, value) → None
Insert or update a list of properties for the specified device.
Parameters:
dev_name:

(str) device name

value:

can be one of the following:

  1. DbData - several property data to be inserted

  2. sequence<DbDatum> - several property data to be inserted

  3. dict<str, dict<str, obj>> keys are attribute names and value being another dictionary which keys are the attribute property names and the value associated with each key being:

    3.1 seq<str> 3.2 tango.DbDatum

Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

put_device_property(self, dev_name, value) → None

Insert or update a list of properties for the specified device.

Parameters:
dev_name:

(str) object name

value:

can be one of the following:

  1. DbDatum - single property data to be inserted
  2. DbData - several property data to be inserted
  3. sequence<DbDatum> - several property data to be inserted
  4. dict<str, DbDatum> - keys are property names and value has data to be inserted
  5. dict<str, obj> - keys are property names and str(obj) is property value
  6. dict<str, seq<str>> - keys are property names and value has data to be inserted
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

put_property(self, obj_name, value) → None
Insert or update a list of properties for the specified object.
Parameters:
obj_name:

(str) object name

value:

can be one of the following:

  1. DbDatum - single property data to be inserted
  2. DbData - several property data to be inserted
  3. sequence<DbDatum> - several property data to be inserted
  4. dict<str, DbDatum> - keys are property names and value has data to be inserted
  5. dict<str, obj> - keys are property names and str(obj) is property value
  6. dict<str, seq<str>> - keys are property names and value has data to be inserted
Return:

None

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)

class tango.DbDatum

A single database value which has a name, type, address and value and methods for inserting and extracting C++ native types. This is the fundamental type for specifying database properties. Every property has a name and has one or more values associated with it. A status flag indicates if there is data in the DbDatum object or not. An additional flag allows the user to activate exceptions.

Note: DbDatum is extended to support the python sequence API.
This way the DbDatum behaves like a sequence of strings. This allows the user to work with a DbDatum as if it was working with the old list of strings.

New in PyTango 7.0.0

class tango.DbDevExportInfo

import info for a device (should be retrived from the database) with the following members:

  • name : (str) device name
  • ior : (str) CORBA reference of the device
  • host : name of the computer hosting the server
  • version : (str) version
  • pid : process identifier
class tango.DbDevExportInfo

import info for a device (should be retrived from the database) with the following members:

  • name : (str) device name
  • ior : (str) CORBA reference of the device
  • host : name of the computer hosting the server
  • version : (str) version
  • pid : process identifier
class tango.DbDevImportInfo

import info for a device (should be retrived from the database) with the following members:

  • name : (str) device name
  • exported : 1 if device is running, 0 else
  • ior : (str)CORBA reference of the device
  • version : (str) version
class tango.DbDevInfo

A structure containing available information for a device with the following members:

  • name : (str) name
  • _class : (str) device class
  • server : (str) server
class tango.DbHistory

A structure containing the modifications of a property. No public members.

class tango.DbServerInfo

A structure containing available information for a device server with the following members:

  • name : (str) name
  • host : (str) host
  • mode : (str) mode
  • level : (str) level