"""Model for asset file details.""" import sqlalchemy from asset_file_details.connectors import mysql from asset_file_details.queries import file_details @mysql.db_session def get_file_details_by_format(file_format, upc, physical_location_id=1, session=None): """Get the details for file from the database. Args: file_format (str): File format. upc (str): UPC of the asset. session (sqlalchemy.orm.session.Session): Database session. physical_location_id: ID of physical location storage Returns: Response: List containing object(s) of result row data. """ result = session.execute( sqlalchemy.text(file_details.get_file_details), {'upc': upc, 'asset_type': file_format, 'physical_location_id': physical_location_id} ) return [dict(row) for row in result.mappings().all()]