Hi John. I wanted a bit more flexibility in a development server so adapted the cherrypy wsgi server to work with Django. In order to use SQLite, I modified my cherrypy config to use a single thread. Also I had to be sure that if I was calling the connection to execute raw SQL, I made sure to close it afterwards. I am still using more than one thread in the app. I found it was easier for me to be explicit about this since I was calling the connection in a number of places in my code. There have been recent changes in SQLite to support pooled threads but I have not yet experimented with the latest code. Hope this helps.
Regards David [EMAIL PROTECTED] wrote: > Hi, > > I searched both mailing lists but didn't find any reference to the > following, hence my post. > > I have written an application that starts a new thread, and as this > thread is executing I want to save data to the database. This worked > when I used postgreSQL, but it failed when I used SQLite. The error > message was: > > ProgrammingError: SQLite objects created in a thread can only be used > in that same thread. > > I discovered this was a feature of pysqlite[1] and that it could be > controlled by a parameter that is passed to the connection_init > method. > > I changed the following line in django.core.db.bankends.sqlite3.py > from: > self.connection = Database.connect(DATABASE_NAME, > detect_types=Database.PARSE_DECLTYPES) > to: > self.connection = Database.connect(DATABASE_NAME, > detect_types=Database.PARSE_DECLTYPES, check_same_thread=0) > > and then validated my application worked. > > I guess this could be added as a variable in settings.py to avoid me > editing django source for my applications. It could have a default > value of 1, this would leave the current mode of operation untouched. > > What do people think? > -John K > > [1] http://tinyurl.com/syud4 > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---