V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
diwuqin
V2EX  ›  问与答

用原生 sql 查询 mysql 数据库时,传参老是报错

  •  
  •   diwuqin · 2019-04-17 15:40:33 +08:00 · 876 次点击
    这是一个创建于 1834 天前的主题,其中的信息可能已经有所发展或是发生改变。

    def user_query(user, table_dict): # 单个用户查询查询数量 try: sql = """SELECT COUNT(id), COUNT(call_result), SUM(hold_time) FROM call_detail WHERE call_result = 'connect' and user_detail_id = {0}; """.format(user[0]) import pdb; pdb.set_trace() print(sql) count_list = db.session.execute(sql) print(count_list) except Exception as e: current_app.logger.error(e) return jsonify(errno=RET.DBERR, errmsg="查询历史号码对象列表异常")

       # user[0]是传过来的一个整数
       ERROR:info:'int' object is not subscriptable			# 查询老是报这句错误, 求大神指教
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5543 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 06:46 · PVG 14:46 · LAX 23:46 · JFK 02:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.