On 18/10/2010 17:57, Michael Bayer wrote:
issue #2, I've tried to emphasize this as much as possible in the documentation, the
SQLite dialect uses *one connection* for the thread, by default. This default is being
changed in 0.7 (so in 0.7, the common issue will become "database is locked"
issues, whereby I'll probably have to tell people to switch back to
SingletonThreadPool.... ).
The "one connection per thread" default is discussed at the following locations:
http://www.sqlalchemy.org/docs/dialects/sqlite.html?highlight=sqlite#threading-behavior
http://www.sqlalchemy.org/docs/core/pooling.html?highlight=singleton#connection-pool-configuration
http://www.sqlalchemy.org/docs/core/pooling.html#sqlalchemy.pool.SingletonThreadPool
This reminds me of an issue that's been niggling me too...
So, I have some unit tests where the basic pattern is:
from zope.sqlalchemy import ZopeTransactionExtension
from zope.sqlalchemy.datamanager import STATUS_CHANGED
import transaction
class SomeTests(UnitTest):
def setUp(self):
engine = create_engine('sqlite://')
self.Session = sessionmaker(
bind = engine,
autoflush=True,
autocommit=False,
extension=ZopeTransactionExtension(
initial_state=STATUS_CHANGED
))
with transaction:
session = self.Session()
... do some table creation, row creation, etc...
self.t = transaction.get()
def tearDown(self):
self.t.abort()
def test_...(self):
session = self.Session()
...
session.flush()
...
...lots more tests...
The problem I have is that despite the fact that I create the engine for
every test, I'm still seeing tables and row entries surviving across
tests, but only when one or more tests fail.
I've tried using NullPool and StaticPool as options to create_engine
with varying degrees of failure.
Am I missing something obvious here? How can I debug what's going on?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.