def query_by_primary_key(session, model, pk_value, primary_key=None):
 pk_name = (primary_key or primary_key_for(model))
 query = session_query(session, model)
 return query.filter((getattr(model, pk_name) == pk_value))

def query_by_primary_key ( session , model , pk_value , primary_key = None ) : pk_name = ( primary_key or primary_key_for ( model ) ) query = session_query ( session , model ) return query . filter ( ( getattr ( model , pk_name ) == pk_value ) )
returns a sqlalchemy query object containing the result of querying model for instances whose primary key has the value pk_value .