from flask import Flask,session from flask_sqlalchemy import SQLAlchemy import config app = Flask(__name__) app.config.from_object(config) db = SQLAlchemy(app) class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer,primary_key=True,au…
error:flask,sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1071, 'Specified key was too long; max key length is 767 bytes') 分析:数据库类型字符不对(默认latin) 解决:ALTER DATABASE `databasename` CHARACTER SET utf8;…
SQLAlchemy问题记录 company price quantity Microsoft Google Google Google 要实现脚本 select price, sum(quantity) as num from shares where company='Google' group by price; SQLAlchemy写法 你实际上需要label()方法. result = dbsession.query(Shares.price, \ func.sum(Shares.qu…