I am using sqlalchemy 0.9 and flask / flask-sqlalchemy.

I want to pass in the name of a table and an id and get back the object.  I 
use reflection to get the table object, but can't seem to a way to get from 
the table object to the mapped object.  I feel like I am missing something 
basic, but I have not been able to find a solution.  I appreciate your help.

Regards,

Brendan

<code>

def get_instance(table_name, instance_id):

    db.metadata.bind = db.engine
    table = Table(table_name, db.metadata,
                  autoload=True, autoload_with=db.engine)

    return table.query.filter(table.id == instance_id).one()

</code> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to