On Sep 6, 2008, at 5:07 PM, gatto wrote:
> > global phase > > try: > if phase == 'start': > phase = 'running' > except: > phase = 'start' > > if phase == 'start': > self.engine = create_engine('mysql://' + app_config.database.user + > ':' + app_config.database.password + '@' + app_config.database.host + > ':3306/' + app_config.database.schema) > metadata.bind = self.engine > metadata.bind.recycle = 3600 this greatly complicates what needs to be done. heres a pseudo mod_python application. "module level" means, "not inside of a def which is called within the request". import sqlalchemy as sa import sqlalchemy.orm as orm engine = sa.create_engine(<url>) meta = sa.MetaData(engine) # define tables # define classes Session = orm.scoped_session(orm.sessionmaker(bind=engine)) from mod_python import apache def handler(req): ret = Session.query(SomeClass).filter(..).all() req.write("Number of objects: " + len(ret)) return apache.OK in the real world, the things above regarding engine, metadata, etc. would be in a different python source file, which you would invoke using "import mymodule" at the same level. > i also have one other concern.. in periods of high traffic, the > number of apache processes might outpace the number of mysql > max_connections i configured (300 at the moment). 300 connections is unbelievably high, and would many hundreds of megs of memory on both client and server. Unless you're eBay, it should hardly be possible to ever use more than 20 or 30 simultaneous connections across your entire application. If your mod_python is using a forked process model, then in fach each connection pool will only use one connection since there is only one request handled per process, in which case the maximum child forks you've configured would determine the actual number of connections opened. > right now. but i'm looking toward the future... perhaps there isn't > much i can do about that until i move on to connection pooling? the SQLA engine always pools connections. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---