在线客服系统
在线客服系统
https://w1011.ttkefu.com/k/linkurl/?t=4G6EA0

解决:sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: ‘select 1‘

2024-09-17

这个程序是用来测试的,你肯定是这么写的?

with app.app_context():

    with db.engine.connect() as conn:

        rs = conn.execute("select 1")

        print(rs.fetchone())


接下来我们需要对上面代码进行修改,如下所示


from sqlalchemy import text

with app.app_context():

  1.     with db.engine.connect() as conn:
  2.         rs = conn.execute(text("select 1"))
  3.         print(rs.fetchone())