从python sqlalchemy调用过程时出错

2020-08-22 05:37发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨 当我使用sqlalchem...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


当我使用sqlalchemy lib从表类型输入和python的varchar out参数调用存储过程时遇到错误。以下是错误

从python sqlalchemy.exc.DatabaseError调用过程时出错:(pyhdb.exceptions.DatabaseError)无效参数:输入参数不足以作为表参数:

第一个参数是表类型,第二个参数是varchar

我正在添加尝试使用的代码段

 engine = create_engine(" hana + pyhdb://{username}:{password} @ {host}:{port}"。format(username ='username',password ='password',host ='hostname'  ,port ='30015'))
 output ="
 数据='[{" RULE_ID":1," RULE_NAME":null," SO_SSA":" 1074"," PO_NUMBER":null," CODE":" DDD"," ROUTE_CODE":""," OPERATING":  null," SHIP_TO":" IND"," SHIP_TO_REGION":" MX"," SHIP_TO_CUSTOMER_ID":null," BILL_TO_CUSTOMER_ID":null," END_TO_CUSTOMER_ID":null," SLCA":" AKP123"," HOLD_NAME":" 批准保留"," SHIPPING_PREFERENCE":null," EAD":null," CUSTOMER_REQUEST_TYPE":null," CRD":null," CRSD":null," CURRENT_PROMISE_DATE":null," CURRENT_PROMISE_DELIVERY_DATE"" ATE:null"  null," OPDD":null," ON_HOLD":null," FLOW_STATUS_CODE":null," PICK_RESULT":null," IS_IN_OTM":null," BUSINESS_UNIT":null," REVENUE_FLAG":null," ACTION_CATEGORY":null,  " ACTION_OWNER":null," SS_REVENUE":null," CARTONS":null," INVOICE_ELIGIBILITY_EVENT":null," SALES_CHANNEL":null," CREATED_BY":" NEW"," CREATION_DATE":" 2020-02-11 10:  24PM"," LAST_UPDATED_BY":" NEW"," LAST_UPDATE_DATE":" 2020-03-04 10:39 PM"," FDA_FLAG":null," POE_FLAG":null," CONSOLIDATED_FLAG":null," START_DATE":" 2019  -01-02"," END_DATE":" 2020-01-02"," ACTIVE":" T"}]]'

 test = engine.execute('call SCHEMA.PROC(?,?)',(数据,输出))
 
4条回答
bbpeas
2020-08-22 05:59

亲爱的Arunkumar

实际上,DB过程应该使用table [],而不是数据字符串。

所以您可能不得不写这样的东西

开始

 -从表中选择值以填充表
    tabledata = SELECT * from xyz;
        
    
  test = engine.execute('call SCHEMA.PROC(?,?)',(tabledata,output))
 END; 

一周热门 更多>