Menu

#148 Make taurus compatible with sqlite tango database

Jan16
resolved
None
feature-request
2016-02-10
2015-03-05
No

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()

~~~~~~~~~~

Discussion

  • Tiago Coutinho

    Tiago Coutinho - 2015-03-30

    Ticket moved from /p/sardana/tickets/336/

    Can't be converted:

    • _category: taurus-tango
     
  • Carlos Pascual

    Carlos Pascual - 2015-07-22
    • Category: Jul15 --> unassigned,
     
  • Carlos Pascual

    Carlos Pascual - 2016-01-19
    • Category: unassigned, --> Jan16,
     
  • Carlos Pascual

    Carlos Pascual - 2016-01-28
    • status: active --> resolved
    • Milestone: Jan16 --> Jan16
     
  • Carlos Pascual

    Carlos Pascual - 2016-01-28

    Proposed approach implemented in develop

     
    • Carlos Pascual

      Carlos Pascual - 2016-01-28

      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
  • Sergi Rubio

    Sergi Rubio - 2016-02-10

    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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.