flask-sqlalchemy 如何使用原生sql | flask-sqlalchemy 返回结果集无表头
原生sql
https://stackoverflow.com/questions/17972020/how-to-execute-raw-sql-in-flask-sqlalchemy-app
配置参数
https://blog.csdn.net/weixin_42289273/article/details/116496820
https://blog.csdn.net/weixin_49278803/article/details/114079482
def fetchall(sql, args=None): if args is None: dataObj = db.session.execute(sql) else: dataObj = db.session.execute(sql, args) data = [dict(zip(result.keys(), result)) for result in dataObj.fetchall()] return data def fetchone(sql, args=None): if args is None: dataObj = db.session.execute(sql) else: dataObj = db.session.execute(sql, args) data = dataObj.fetchone() if data is None: return None data = dict(zip(dataObj.keys(), dataObj.fetchone())) return data