On Feb 4, 2008, at 8:34 PM, braydon fuller wrote:

>
> I am using the following to establish get the database going:
>
> import cherrypy
>
> from sparrow.settings import Settings
> from sparrow.database import Database
> from sparrow.templates import render
>
> db = Database()
> settings = Settings()
>
> class Root():
>    def __init__(self):
>        self.cmd = __import__('exposed', globals(), locals(), 
> ['sparrow'])
>    db.create_all()
>
>    def default(self, *args, **kwargs):
>        location_st = ""
>        for arg in args:
>            location_st += "/"+arg
>        try:
>            return render(args, kwargs, location_st)
>        except:
>            db.start_engine()
>            return render(args, kwargs, location_st)
>    default.exposed = True
>
> This is the wrong way to go about insuring
> that there is a DB connection. I'd like to know the correct way.
> Would this be to test the database, and if that fails to open a  
> connection?


well I dont know cherrypy so i dont see anything familiar to me there.  
but as far as SA is concerned, it would like you to create a single  
engine just once in your application.  after that you dont need to  
worry about ensuring the DB is connected, it takes care of it for you.



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to