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?
--