You should make sure it's accessing the correct file and that the table 
really exists in that database.

Anthony

On Wednesday, October 22, 2014 3:26:50 PM UTC-4, Richard wrote:
>
> But I am refering to an existing database with data in that table. When I 
> put the line  db(db.langu.id>0).select()  in db.py in the app  wemanops_test 
> 3 records are returned.
>
> I expect that the model on an existing db would expose the data.
>
>
>
> On Wednesday, October 22, 2014 4:58:59 PM UTC+2, Richard wrote:
>>
>> Hi,
>>
>> I want to access an existing database from an outside web2py app script 
>> because the database must be input to Orange for data mining.
>>
>> I tried the following defining but dot not get access top the data:
>>
>> import os
>>
>> import sys
>>
>> import datetime
>>
>> import calendar
>>
>> from datetime import date, time
>>
>> import json
>>
>> import uuid
>>
>> sys.path.append("c:\python27\web2py")
>>
>>
>> from gluon.sql import *
>>
>> from gluon.validators import *
>>
>>
>> module_path = 
>> os.path.abspath(os.path.dirname('C:\\web2py\\applications\\wemanops_test\\databases'))
>>
>> db_name='storage.sqlite'
>>
>>
>> db = DAL('sqlite://storage.sqlite', pool_size=1, folder=module_path, 
>> migrate=False, check_reserved=['all'])
>>
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>>
>> auth = Auth(db)
>>
>>
>> db.define_table('langu',
>>
>> Field('langu', 'string'),
>>
>> format='%(langu)s'
>>
>> )
>>
>>
>> db.define_table('community',
>>
>> Field('com_name', 'string', length=15),
>>
>> Field('address', 'string'),
>>
>> Field('responsible', 'string'),
>>
>> Field('latitude', 'string', default=None),
>>
>> Field('longitude', 'string', default=None),
>>
>> #User creation can not beadded because mutial dependence of the auth Class
>>
>> Field('created_date', 'datetime', default=datetime.datetime.now()),
>>
>> format='%(com_name)s'
>>
>> )
>>
>>
>> auth.define_tables(username=True, signature=True, migrate=False)
>>
>>
>> print db(db.langu.id>0).select()
>>
>>
>> The error I get is:
>>
>> Traceback (most recent call last):
>>
>> File "<console>", line 1, in <module>
>>
>> File "<string>", line 22, in <module>
>>
>> File "c:\python27\web2py\gluon\tools.py", line 1268, in __init__
>>
>> request = current.request
>>
>> AttributeError: 'thread._local' object has no attribute 'request'
>>
>>
>> What is missing? 
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to