How to explicitly cast type of array literal in sqlalchemy using postgresql?

前端 未结 1 393
深忆病人
深忆病人 2021-01-19 01:22

After attempting to cast a literal arrays type via cast, type_coerce, and type_ and not having any success thought I would ask.

from pprint import pprint

fr         


        
1条回答
  •  时光说笑
    2021-01-19 02:15

    Casting is very straightforward:

    from sqlalchemy.dialects.postgresql import array, ARRAY
    
    cast(array([]), ARRAY(Integer))
    

    Without seeing what you've tried, I can only speculate that you tried to cast to array(Integer) instead of ARRAY(Integer).

    0 讨论(0)
提交回复
热议问题