On Tue, May 20, 2008 at 2:18 AM, Karlo Lozovina
<[EMAIL PROTECTED]> wrote:
>
> Hi all, is this:
>
> http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
>
> the new default, preferred way of using SQLalchemy with Pylons?

Yes.  If you create a new app in Pylons' development version, it will
ask if you want SQLAlchemy, and if so it will preconfigure the model
according to that article.

> It
> seems now I have to add something like:
>
> engine = engine_from_config(config, 'sqlalchemy.')
> init_model(engine)

This is done in environment.py, as shown in "The Engine" section of
the article.  It is not normally done in the base controller.

> otherwise I get errors like:
>
> <class 'sqlalchemy.exceptions.ProgrammingError'>: (ProgrammingError)
> SQLite objects created in a thread can only be used in that same
> thread.The object was created in thread id -1224172656 and this is
> thread id -1249350768 None [{}]

SQLite does use one connection per thread, while other engines may
give out multiple connections in one thread.  You shouldn't have to
use the "threadlocal" engine strategy; it's built into the SQLite
engine.

But I don't know why it would use the wrong connnection in a thread.
Nobody else has reported this problem.  When exactly does this occur,
and what kinds of queries does your application contain?

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to