Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Reading 2D attributes #17

Open
cpt-majkel opened this issue Oct 11, 2020 · 2 comments
Open

Reading 2D attributes #17

cpt-majkel opened this issue Oct 11, 2020 · 2 comments
Assignees

Comments

@cpt-majkel
Copy link

Hi,

i'm trying to read 2D attribute. It is an image (att_array_devdouble). Here is my code snippet:

from PyTangoArchiving import Reader

rd = Reader(db="hdbpp", config="pim:pam@pom")

image = 'r1-01/dia/r1-01-dia-bpmccd01/resimage'

val = rd.get_attribute_values(image, start_date='2020-10-06 7:00', stop_date="2020-10-06 7:02")

and here is what i get:

None.Reader WARNING 2020-10-11 17:08:23.268: In PyTangoArchiving.Reader.get_attribute_values(hdbpp,r1-01/dia/r1-01-dia-bpmccd01/resimage,2020-10-06 07:00:00,2020-10-06 07:02:00)
HDBpp WARNING 2020-10-11 17:08:23.268: HDBpp.get_attribute_values(r1-01/dia/r1-01-dia-bpmccd01/resimage,2020-10-06 07:00:00,2020-10-06 07:02:00,0,decimate=0,{})
HDBpp   ERROR 2020-10-11 17:08:23.304: Query(select CAST(UNIX_TIMESTAMP(data_time) as DOUBLE),idx,value_r,quality from att_array_devdouble_ro where att_conf_id = 2752 and data_time between '2020-10-06 07:00:00' and '2020-10-06 07:02:00' order by data_time) failed!
HDBpp WARNING 2020-10-11 17:08:23.304: HDBpp.get_attribute_values((2752L, 39L, 'att_array_devdouble_ro'),2020-10-06 07:00:00,2020-10-06 07:02:00,0,decimate=0,{})
HDBpp   ERROR 2020-10-11 17:08:23.331: Query(select UNIX_TIMESTAMP(data_time),idx,value_r,quality from att_array_devdouble_ro where att_conf_id = 2752 and data_time between '2020-10-06 07:00:00' and '2020-10-06 07:02:00' order by data_time) failed!
get_attribute_values(*(<PyTangoArchiving.hdbpp.config.HDBpp object at 0x7f6e22d770d0>, (2752L, 39L, 'att_array_devdouble_ro'), '2020-10-06 07:00:00', '2020-10-06 07:02:00', False, 0, True, 'quality', 0, False),**{'as_double': False}) failed!
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 113, in execute
    return self.f(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/hdbpp/config.py", line 640, in get_attribute_values
    result = self.Query(query)
  File "/usr/local/lib/python2.7/dist-packages/fandango/db.py", line 232, in Query
    q.execute(query)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'idx' in 'field list'")

get_attribute_values(*(<PyTangoArchiving.hdbpp.config.HDBpp object at 0x7f6e22d770d0>, 'r1-01/dia/r1-01-dia-bpmccd01/resimage', '2020-10-06 07:00:00', '2020-10-06 07:02:00'),**{'unixtime': True, 'N': 0}) failed!
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 113, in execute
    return self.f(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/hdbpp/config.py", line 645, in get_attribute_values
    as_double=False,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 96, in __call__
    return self.execute(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 113, in execute
    return self.f(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/hdbpp/config.py", line 640, in get_attribute_values
    result = self.Query(query)
  File "/usr/local/lib/python2.7/dist-packages/fandango/db.py", line 232, in Query
    q.execute(query)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'idx' in 'field list'")

Traceback (most recent call last):
  File "/home/michal/pycharm/data/main.py", line 18, in <module>
    val = rd.get_attribute_values(image, start_date='2020-10-06 7:00', stop_date="2020-10-06 7:02")
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/reader.py", line 856, in get_attribute_values
    asHistoryBuffer, N, notNone, GET_LAST)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/reader.py", line 938, in get_attribute_values_from_db
    N=N,unixtime=True)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 96, in __call__
    return self.execute(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 113, in execute
    return self.f(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/hdbpp/config.py", line 645, in get_attribute_values
    as_double=False,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 96, in __call__
    return self.execute(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/utils.py", line 113, in execute
    return self.f(*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/PyTangoArchiving/hdbpp/config.py", line 640, in get_attribute_values
    result = self.Query(query)
  File "/usr/local/lib/python2.7/dist-packages/fandango/db.py", line 232, in Query
    q.execute(query)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'idx' in 'field list'")

Data is there (checked by a Viewer). What am i doing wrong here? If i do a query with scalar attributes everything works perfectly fine.
I use PyTangoArchiving 8.3.1, fandango 14.8.0, MySQL-python 1.2.5 and PyTango 9.2.5

Cheers,
Michal

@sergirubio
Copy link
Collaborator

Hi, sorry for the late answer

It is a bug with the column schema. Anyway I updated the code in github to the latest version, but if you try and it fails again then please paste the result of this code (update to latest fandango):

api = PyTangoArchiving.HDBpp(host='...',db_name='hdbpp',user='...',passwd='...')
table = api.get_attr_id_type_table(attribute)[-1]
print(api.getTableCreator(table))

Hope it helps,

Sergi

@sergirubio sergirubio self-assigned this Dec 9, 2020
@sergirubio
Copy link
Collaborator

Hi,

If possible, login to gitlab, as the project has been moved there, and comment with your own username:

https://gitlab.com/tango-controls/hdbpp/libhdbpp-pytangoarchiving/-/issues/17

Did you tried the code I pasted above? Keep in mind that PyTangoArchiving is currently python 2 only (at the moment).

If you need DB access from python 3, try:

https://gitlab.com/tango-controls/hdbpp/libhdbpp-python

Sergi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants