I get the following error when call SQL table, when I have reference
fields in my data table.
E.g.:

db.define_table('alarms',
    SQLField('function_name', 'string', length=64),
    SQLField('created_at', 'datetime',
default=datetime.datetime.now()),
    SQLField('header', db.headers),
    SQLField('time_based', db.time_based, required=False),
    SQLField('komment', 'string', length=255),
    SQLField('ack_at', 'datetime', default=None, notnull=False),
    SQLField('detail', db.details, required=False),
    SQLField('investigation', db.investigations),
    SQLField('internals', 'text'),
)
alarms_rs = db(eval(terms)).select( orderby=alarms_orderby,
 
limitby=session.alarms_limitby,
                                        )
print alarms_rs #prints query results into console window, no errors
at this point
alarms_tbl = SQLTABLE(alarms_rs,
                    _class='sortable',
                    headers=headers_dict,
                    truncate = 200,
                    orderby=True)

At this point error occures for the field SQLField('investigation',
db.investigations).
Here is a traceback:


Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 181, in restricted
    exec ccode in environment
  File "C:/web2py/applications/advantage/controllers/alarms.py", line
842, in <module>
  File "C:\web2py\gluon\globals.py", line 133, in <lambda>
    self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 2335, in f
    return action(*a, **b)
  File "C:/web2py/applications/advantage/controllers/alarms.py", line
137, in alarms_table
    orderby=True)
  File "C:\web2py\gluon\sqlhtml.py", line 1366, in __init__
    elif linkto and hasattr(field._table,'_primarykey') and fieldname
in field._table._primarykey:
  File "C:\web2py\gluon\dal.py", line 3457, in repr_ref
    def repr_ref(id, r=referenced, f=ff): return f(r, id)
  File "C:\web2py\gluon\dal.py", line 3426, in ff
    row=r(id)
  File "C:\web2py\gluon\dal.py", line 4387, in __call__
    record = self._db(self.id == key).select(limitby=(0,1)).first()
  File "C:\web2py\gluon\dal.py", line 5164, in select
    return self.db._adapter.select(self.query,fields,attributes)
  File "C:\web2py\gluon\dal.py", line 1077, in select
    rows = response(sql)
  File "C:\web2py\gluon\dal.py", line 1067, in response
    self.execute(sql)
  File "C:\web2py\gluon\dal.py", line 1152, in execute
    return self.log_execute(*a, **b)
  File "C:\web2py\gluon\dal.py", line 1147, in log_execute
    ret = self.cursor.execute(*a,**b)
  File "C:\web2py\gluon\contrib\pymysql\cursors.py", line 108, in
execute
    self.errorhandler(self, exc, value)
  File "C:\web2py\gluon\contrib\pymysql\connections.py", line 182, in
defaulterrorhandler
    raise Error(errorclass, errorvalue)
Error: (<type 'exceptions.AssertionError'>, AssertionError('Protocol
error, expecting EOF',))


I tried to workaround by adding format to 'investigations' table, set
represent=None to fields in question, this won't help. If
db.alarms.investigation field is empty (None) error does not occur.
MySQL console lets me select the record in investigations field, there
are no problems with data.

Looks like pymysql gives so many problems, won't it be better to go
back to dbmysql? pymysql works 20% slower on my PC, application admin
is not working on Windows and Debian installations since web2py
version 1.92 (I reported on this usergroup)... why so many problems
with contrib module?

Reply via email to