In order to open the possibility not requiring a Mysql installation for trying/testing taurus, the TangoDatabaseCache class needs to be modified (right now it relies on a mysql-specific command on the DB server).
srubio proposed the following workaround:
~~~~~~~~~
class TangoDatabaseCache(TaurusDatabaseCache):
def refresh(self):
db = self.db
if hasattr(taurus.Device(db.dev_name()),'DbMySqlSelect'):
query = "SELECT name, alias, exported, host, server, class FROM device"
r = db.command_inout("DbMySqlSelect", query)
row_nb, column_nb = r[0][-2], r[0][-1]
results, data = r[0][:-2], r[1]
assert row_nb == len(data) / column_nb
else:
#Doing the same query in several tango commands
#The first 2 calls are fast, but the following could be very slow when having more than 1000 devices
data=[]
all_devs = db.get_device_name('*','*')
all_exported = db.get_device_exported('*')
all_alias = dict((db.get_device_alias(k),k) for k in db.get_device_alias_list('*')) #Time intensive!!
for d in all_devs:
name,ior,level,server,host,started,stopped = db.command_inout("DbGetDeviceInfo",d)[1]
klass = db.get_class_for_device(d)
alias = all_alias.get(d,'')
exported = str(int(d in all_exported))
data.extend((name, alias, exported, host, server, klass))
row_nb, column_nb = len(data),6
#From this line ... business as usual
CD = CaselessDict
dev_dict, serv_dict, klass_dict, alias_dict = CD(), {}, {}, CD()
~~~~~~~~~~
Ticket moved from /p/sardana/tickets/336/
Can't be converted:
Proposed approach implemented in develop
Note: I tested the alternative fallback with a MySQL DB (temporarily disabling the MySQL optimization), but I did not test with a sqlite db since I did not have it set-up. It would be nice if someone (perhaps the requestor?) confirms that the current develop (i.e., commit [bb3f2b]) works with sqlite.
Related
Commit: [bb3f2b]
Last edit: Carlos Pascual 2016-01-28
Well, the good news are that this change works well ... the bad ones are that it help me to discover more unexpected bugs in the PyDatabaseDS device (sigh).
Last edit: Sergi Rubio 2016-02-10