So as i understood, i need again re-establish the db connection before
purging the records from the table , like below:

@sched.interval_schedule(seconds=15)
def purge_appliance_tbl():
    yesterday = request.now - datetime.timedelta(days=1)
    db = DAL('sqlite://storage.sqlite')
    db(db.appliance_tbl.created_on < yesterday).delete()

is it correct? OR do I need to re-define all the tables for local db
instance?if no, then how this instance will be able to recognize all tables?

Please guide me to resolve this.

Thanks,
Amit

On Wed, Aug 8, 2012 at 10:49 PM, Massimo Di Pierro <
[email protected]> wrote:

> yes. it should
>
> On Wednesday, 8 August 2012 11:36:58 UTC-5, Anthony wrote:
>>
>> SQLite ignores the pool_size parameter, though, right? In any case,
>> shouldn't a background task run through the scheduler be able to establish
>> a db connection, even without pooling?
>>
>> Anthony
>>
>> On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Normally you would do
>>>
>>> db = DAL('sqlite://storage.**sqlite',pool_size=10)
>>>
>>> where 10 is the max number of connections to keep alive and to be
>>> recycled across multiple requests.
>>> I am not sure how this interact with scheduler.
>>>
>>> On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>>>>
>>>>
>>>> Hi,
>>>> I am using SQlite database for my web2py application, I have to keep
>>>> the same db instance which is created at first time request comes to model
>>>> db.py
>>>>
>>>>
>>>> db = DAL('sqlite://storage.sqlite')
>>>>
>>>> database connection is getting closed once request is completed so I am
>>>> not able to use the "db" for some background process like purging the
>>>> records every day so can anyone suggest me the proper way to keep the
>>>> database connection alive irrespective of request?
>>>>
>>>> Scenario:
>>>> 1. when first time request made , db connection is established, I need
>>>> to keep this connection alive
>>>> 2. One background scheduler running continuously to check the records
>>>> in db and purge it based on some condition.
>>>>
>>>> Problem facing:
>>>> when first request made and get fulfilled, database connection is
>>>> getting closed because of that scheduler is not able to use the db instance
>>>> and start throwing error "Cannot operate on a closed database." every time
>>>> when it tries to execute the job.So I need to keep the "db"instance
>>>> connected to db , how can it be achieved?
>>>
>>>  --
>
>
>
>

-- 



Reply via email to