Pedro,
I don't really have much of anything special as far as the connection
goes--SQLAlchemy already does a pretty awesome job of handling all
that for you. I just keep a module-level variable that I can import
as needed, and call a function in that module to set up the connection
with
On Mar 11, 2:13 pm, 一首诗 newpt...@gmail.com wrote:
Hi Jeff,
In my project I use the *model* to indicate an instance of Database.
I don't really need multiple instances of Database. But when I wrote
unit test, I always create an new one database in setup, which create
a new sqlite in
Logging SA objects *after* the session is gone will always be a
problem, unless you make sure to detach all of them from the session.
I'd just log the original request, instead. In my case, I have to
convert all of my SA objects to something Perspective Broker
understands, so I actually log
Hi Jeff,
In my project I use the *model* to indicate an instance of Database.
I don't really need multiple instances of Database. But when I wrote
unit test, I always create an new one database in setup, which create
a new sqlite in memory database to avoid conflicts between test cases.
About
Hi Jeff,
Thanks for your kind suggestion.
I first add some log decorators, but i found when it might cause to
print sqalchemy objects which has not been bound to any session.
And I am not quite sure about how to make the decorator mor genreal.
Actually, I think I must use model as the first
Don't use scoped_session--you'll run into problems no matter what you
do. I'm using Perspective Broker from Twisted with SQLAlchemy. I
make sure to create and commit/rollback a session for *every* PB
request. It works perfectly, and that's the only way I was really
able to get it to work in
Hi 一首诗,
what database engine are you using? On PostgreSQL at least, table
creation and dropping (and some other operations) take an ACCESS
EXCLUSIVE lock on the database, and will wait for this lock
indefinitely if there are open transactions hanging around. My app
creates and drops tables
I'm not quite sure, but I think I'm pretty careful of sharing objects
between threads.
1st, I only cached as few as possible orm objects. I tried to detach
them, but I found that if I detach them, I can't access any of their
fields any more.
2nd, I create new orm objects based on client