I suppose you have somewhere 
my_legacy_db = DAL(...)

In the "db()" part, you need a query (unless in the select, you have the 
list of fields (not tables) to retrieve), like:
my_legacy_db(my_legacy_db.users.id > 0) or 
my_legacy_db(my_legacy_db.users.name.contains('foo'))
or (selectgin fields) :
my_legacy_db().select(my_legacy_db.users.ALL) or 
my_legacy_db().select(my_legacy_db.users.email,my_legacy_db.users.username)

Then you can select a specific field:
my_legacy_db(my_legacy_db.users.id > 0).select(my_legacy_db.users.email)
Or you can count distinct elements (like names ?)
my_legacy_db().count(my_legacy_db.users.name, distinct=True)

Le samedi 21 avril 2012 14:08:50 UTC+2, Cody Goodman a écrit :
>
> Well I tried that, and it gave me:
>
> In [2] : db(db.legacy_db.table).select()
> Traceback (most recent call last):
>   File "/opt/web-apps/web2py/gluon/contrib/shell.py", line 233, in run
>     exec compiled in statement_module.__dict__
>   File "<string>", line 1, in <module>
>   File "/opt/web-apps/web2py/gluon/dal.py", line 6343, in __getattr__
>     return self[key]
>   File "/opt/web-apps/web2py/gluon/dal.py", line 6337, in __getitem__
>     return dict.__getitem__(self, str(key))
> KeyError: 'legacy_db
>
> I believe that the DAL doesn't like how my database is made, so I'm just 
> going to rebuild it with the ORM in web2py.'
>
> On Friday, April 20, 2012 3:26:07 PM UTC-5, Khalil KHAMLICHI wrote:
>>
>> db(db.legacy-db.table).select()
>>
>> I think you are forgetting "db." in front of table name.
>>  
>

Reply via email to