Hi everyone,
I'm trying to access the data stored in my app db from a different piece of
software (apart from my web2py app). But I get an error AttributeError.

Based on the manual:

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Using-DAL-without-define-tables

I used the code below (from IDLE):

import sys

sys.path.append(r'C:\Users\Jon\Downloads\web2py_src\web2py\gluon')

from gluon import DAL

dbpath =
r'C:\Users\Jon\Downloads\web2py_src\web2py\applications\xakemate_scratch\databases'
problemsuri = 'mysql://root:web2py@localhost/xakemate'
pos = 'test_position'

db = DAL(problemsuri,folder=dbpath,auto_import=True)
query = (db.problem.fen == pos)
problem = db(query).select(orderby=db.problem.id).first()

I get the following error:

Traceback (most recent call last):
  File "<pyshell#33>", line 1, in <module>
    query = (dbproblems.problem.fen == posFEN)
  File "C:\Python27\lib\site-packages\gluon\dal.py", line 7150, in
__getattr__
    return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'problem'

>From what I understood the tables should be auto-imported and thus known to
my code. Why is it not finding the table?

In addition to that I've got a couple of questions:

1st Should I import PYDAL (from pydal import DAL)  or GLUON.DAL (as I did)?

2nd Even when using the db different from SQLite should we point to
"applications/myapp/databases"?

Thanks in advance, Jon.

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Libre
de virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to