the SQLAlchemy engine corresponds to a single connection URL. if you
want to close all connections, call dispose() on the engine.
if you want an engine that remains, but does not "pool" the
connections and literally closes the connection for each close()
operation, you can try creating a "fake" connection pool, (this could
be added to the dist):
import sqlalchemy.pool as pool
class FakePool(pool.Pool):
def status(self):
return "FakePool"
def do_return_conn(self, conn):
conn.close()
def do_return_invalid(self, conn):
pass
def do_get(self):
return self.create_connection()
then create the engine:
e = create_engine(url, poolclass=FakePool)
On Oct 24, 2006, at 8:07 AM, Gary D wrote:
>
> In my utility using SA against MS SQLServer I'm trying to properly
> disconnect from a database and connect to another one. I can't seem to
> find an easy way to do this. Closing a connection just puts that
> connection back into the pool. I don;t want to do that.
>
> I have many (100+) databases on several SQLServer servers that I want
> to connect, do stuff, disconnect and move onto the next one. I don't
> want to accumulate hundreds of connections until the program quits.
>
> Currently I'm doing this to connect to a database:
>
> db = create_engine('mssql://sa:[EMAIL PROTECTED]/she9832')
> connection = db.connect()
> metadata.connect(db)
> session = create_session(bind_to=db)
>
> where metadata is a DynamicMetaData instance.
>
> What's the recommended way of doing this sort of thing?
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---