'SQLAlchemy map function output to model

I'm using

  • Python 3.5
  • Flask (0.12)
  • SQLAlchemy (1.3.19) with postgres (12.9).

I have sql function with int array parameter

public.get_something(array[1,2,3,4,5])

which returns table with 15 fields.

Is there a way to create SQLAlchemy model to map that 15 fields and query data from function output. I want to make it as clean as possible, like standard table querying - session.query(SomeModel).all() ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source