心云晓辉 2022-04-01 05:14 采纳率: 25%
浏览 249
已结题

python flask数据库查询报错。

学习python flask报错找不到原因,数据库查询出错。非常感谢!

img

img


builtins.TypeError
TypeError: 'float' object is not callable

Traceback (most recent call last)
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "X:\Python\Python39\Lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "X:\Python\Python39\Lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "X:\Python\Python39\Lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\python\Move\app\admin\views.py", line 15, in login
if form.validate_on_submit():
File "X:\Python\Python39\Lib\site-packages\flask_wtf\form.py", line 101, in validate_on_submit
return self.is_submitted() and self.validate()
File "X:\Python\Python39\Lib\site-packages\wtforms\form.py", line 310, in validate
return super(Form, self).validate(extra)
File "X:\Python\Python39\Lib\site-packages\wtforms\form.py", line 152, in validate
if not field.validate(self, extra):
File "X:\Python\Python39\Lib\site-packages\wtforms\fields\core.py", line 204, in validate
stop_validation = self._run_validation_chain(form, chain)
File "X:\Python\Python39\Lib\site-packages\wtforms\fields\core.py", line 224, in _run_validation_chain
validator(form, self)
File "C:\python\Move\app\admin\forms.py", line 46, in validate_account
admin = Admin.query.filter_by(name=account).count()
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 3113, in count
return self.from_self(col).scalar()
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 2866, in scalar
ret = self.one()
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 2837, in one
ret = self.one_or_none()
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 2807, in one_or_none
ret = list(self)
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 2878, in iter
return self._execute_and_instances(context)
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\orm\query.py", line 2901, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\engine\base.py", line 948, in execute
return meth(self, multiparams, params)
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\sql\elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\engine\base.py", line 1055, in _execute_clauseelement
ret = self._execute_context(
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\engine\base.py", line 1147, in execute_context
fn(self, cursor, statement, parameters,
File "X:\Python\Python39\Lib\site-packages\sqlalchemy\events.py", line 624, in wrap_before_cursor_execute
orig_fn(conn, cursor, statement,
File "X:\Python\Python39\Lib\site-packages\flask_sqlalchemy_init
.py", line 252, in before_cursor_execute
context._query_start_time = _timer()
TypeError: 'float' object is not callable
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object

展开全部

  • 写回答

4条回答 默认 最新

  • sxn777 2022-04-02 03:20
    关注

    查看name的数据类型吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    心云晓辉 2022-04-02 05:13

    初学,是查数据库name的数据库类型吗?

    回复
    sxn777 回复 心云晓辉 2022-04-02 06:48

    不是,TypeError: 'float' object is not callable这句话的意思是 TypeError:“float”对象不可调用
    也就是数据类型不对,你截的图看不出来是哪一行报的错,你可以把你接受到的参数或者从数据库取得数据打印一下数据类型(type)看看

    回复
查看更多回答(3条)
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 4月15日
  • 已采纳回答 4月8日
  • 修改了问题 4月1日
  • 创建了问题 4月1日

悬赏问题

  • ¥15 传人记程序做的plc 485从机程序该如何写
  • ¥15 已知手指抓握过程中掌指关节、手指各关节和指尖每一帧的坐标,用贝塞尔曲线可以拟合手指抓握的运动轨迹吗?
  • ¥50 libwebsockets 如何添加其他socket事件回调
  • ¥50 实现画布拖拽算子排布,通过flink实现算子编排计算,请提供思路
  • ¥15 esium自定义材质拉伸问题
  • ¥15 cmake+mingw使用<mysqlx/xdevapi.h>报错
  • ¥15 eNSP中防火墙的使用
  • ¥15 关于#mlnet#的问题:mlnet相关请求(语言-c#)
  • ¥15 lvgl7.11怎么做出文字被选中的效果
  • ¥50 如何快速查看手机目标app的主要服务器ip
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部