Hi,

I have been trying to connect to a remote read only mysql database. This is 
an existing production database,  I want to use web2py to display it's data 
graphically .  

I can read from it using  dby.executesql('SELECT * FROM test;') but not 
using  dby().select(dby.test.ALL). 

The example is 
dby = DAL('mysql://guest@10.113.131.67/newdb', pool_size=0)
dby.define_table('test', Field('test_id', 'string'), Field('title', 
'string'), Field('description', 'string'), migrate=False)
 
I get the following error

>>> print dby().select(dby.test.ALL)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 5697, in select
    return self.db._adapter.select(self.query,fields,attributes)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1233, in select
    rows = response(sql)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1223, in response
    self.execute(sql)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1309, in execute
    return self.log_execute(*a, **b)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1304, in log_execute
    ret = self.cursor.execute(*a,**b)
  File "C:\Users\msimpson\Downloads\web2py_src 
1_99_2\web2py\gluon\contrib\pymy
ql\cursors.py", line 108, in execute
    self.errorhandler(self, exc, value)
  File "C:\Users\msimpson\Downloads\web2py_src 
1_99_2\web2py\gluon\contrib\pymy
ql\connections.py", line 184, in defaulterrorhandler
    raise errorclass, errorvalue
InternalError: (1054, u"Unknown column 'test.id' in 'field list'")
>>>

it's mysql schema is

CREATE TABLE test
  (
  test_id         VARCHAR(64) NOT NULL,
  title           VARCHAR(1024),
  description     VARCHAR(1024),
  PRIMARY KEY (test_id)
  );

Has anyone seen this before, what am I doing wrong

Regards

Matt  

Reply via email to