Stored procedures SQLAlchemy从postgresql存储过程获取输出参数

Stored procedures SQLAlchemy从postgresql存储过程获取输出参数,stored-procedures,sqlalchemy,postgresql-9.2,output-parameter,Stored Procedures,Sqlalchemy,Postgresql 9.2,Output Parameter,我正在使用Postgresql9.2和SQLAlchemy0.8。我在数据库中有一个存储过程,它有许多out参数,我希望它们用点表示法。但到目前为止,我失败得很惨。下面是我的代码的样子 下面是一个例子来说明我在做什么 CREATE OR REPLACE FUNCTION stored_proc_name(IN in_user_id bigint, IN in_amount bigint, OUT pout_one bigint, OUT pout_two bigint ) RETUR

我正在使用Postgresql9.2和SQLAlchemy0.8。我在数据库中有一个存储过程,它有许多out参数,我希望它们用点表示法。但到目前为止,我失败得很惨。下面是我的代码的样子

下面是一个例子来说明我在做什么

CREATE OR REPLACE FUNCTION stored_proc_name(IN in_user_id bigint, IN in_amount bigint,
OUT pout_one bigint, OUT pout_two bigint )
      RETURNS record AS
$BODY$
begin
    select count(*) as AliasOne into pout_one from tabe_names where conditions;
    select user_name as AliasTwo into pout_two from table_name where condition;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION stored_proc_name(bigint, bigint)
  OWNER TO postgres; 
我的代码片段如下所示:

#session object from sessionmaker
result_obj = session.execute(func.stored_proc_name(user_id, amount))
print result_obj.fetechall()
#The above print statement prints following on the console.
>> [('(1,100)',)]
显然,上面的结果获取字符串。我想要的是类似于
result\u obj.pout\u one的东西,并在我的代码中使用它

有没有办法实现这一目标。工作代码片段将受到高度赞赏


非常感谢

您可以尝试以下方法:

query = select([column('pout_one'), column('pout_two')], 
               from_obj=[func.stored_proc_name(user_id, amount)])
session.execute(query)

这一点的灵感来自SQLAlchemy列表,其中有人问了一个问题。这可能会产生所需的输出(我现在无法测试)。

太棒了!谢谢。还必须添加
列类型