On 23 Gen, 20:46, Rick Morrison <rickmorri...@gmail.com> wrote:
> > > his answer here:
> >http://groups.google.com/group/pyodbc/browse_thread/thread/320eab14f6...
>
> You say in that thread that you're already turning off the setting by
> issuing:
>
>    import pyodbc
>    pyodbc.pooling = False
>
> before you ever open an SQLAlchemy connection.
>
> Is that still the case?

Yes. I've tried with raw pyodbc and the code:

import pyodbc
pyodbc.pooling = False
c = pyodbc.connect('DRIVER={SQL
Server};SERVER=localhost;DATABASE=DB_TEST;UID=sa;PWD=pass') # This
opens a "real" connection
c.close()
del c

closes the connection.

So i've tried another session like this:
import pyodbc
pyodbc.pooling = False
sa_engine=sa.create_engine(dbUri, echo=False, strategy='threadlocal')
sa_Session = sa.orm.scoped_session( sessionmaker(bind=sa_engine,
autoflush=False) )
metadata = sa.MetaData(sa_engine)
sa_session = sa_Session()

# Some queries in here ( and is only when i fire the first query that
Sql Server Profilers tells me that a connection is opened )

sa_session.close()
sa_Session.close_all()
sa_engine.dispose()
del sa_session
del sa_Session
del sa_engine


but it does not close the connection!

> That would imply that the connection is being held
> open by SQLAlchemy, not the ODBC connection pooling.

mmm.. Yes... that wath i thought at first too. But it's just a case
that pyodbc with pooling = True have the same behavior?

> So Mike's original
> advice about using the NullPool should close the connections when you're
> done with them -- did that work for you?

Yes. But it's behavior is a little bit different. With NullPool every
database action opens and closes a connection. So basically the
connection is created every time i need it.
With pyodbc.pooling = False ( in raw pyodbc, and that's what i'd
expect with SA too... but maybe i'm wrong ) it opens a connection (  c
= pyodbc.connect('bla bla') ) and keeps it alive until I do c.close()

>
> Mike / Jason: Wasn't there also some sort of "verify connection" feature
> that was added in the 0.5 series that would issue a do-nothing query on a
> connection when it was checked out from a pool just to make sure the
> connection was still working?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to