Hi,

this code is a bit old and I'm not sure it'll work with latest webpy
or SQLAlchemy so use with caution:

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
engine = create_engine(
    'mysql://user:[EMAIL PROTECTED]/yourdb?unix_socket=/path/to/
mysqld.sock',
    echo = True,
    pool_recycle = 60,
    pool_timeout = 30,
    pool_size = 1,
    max_overflow = 5
)

def loadsa():
    session = scoped_session(
        sessionmaker(
            autoflush=True,
            transactional=True,
            bind=engine
        )
    )
    web.ctx.sadbsession = session
    web.ctx.sadb = session()
app.add_processor(web.loadhook(loadsa))

def unloadsa():
    web.ctx.sadb.close()
    web.ctx.sadbsession.remove()
app.add_processor(web.unloadhook(unloadsa))

After you'll be able to call something like:

web.ctx.sadbsession.query(YourClass).filter(YourClass.id==int(id)).all()


On Jun 9, 4:50 am, "paul jobs" <[EMAIL PROTECTED]> wrote:
> http://www.google.com/search?q=sqlachemy+webpy
> cant find it
> can u pls share
> On 6/8/08, MilesTogoe <[EMAIL PROTECTED]> wrote:
>
>
>
> > paul jobs wrote:
> > > how do we add orms such as sqlalchemy in webpy
> > > in an elegant manner such as using add_processor or something like that?
> > > and can some one please share an example of using sqlalchemy with webpy
>
> > there was an article on this - google for it (I think it was in Russian
> > but google translates it)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to