错误'函数和(字符变化)不存在'使用SQL与Alchemy和Postgres的和

时间:2014-06-10 06:27:33

标签: postgresql sqlalchemy flask-sqlalchemy

在我的SQL Alchemy查询中尝试使用func.sum时出现以下错误:

  

ProgrammingError :( ProgrammingError)函数和(字符变化)   不存在LINE 1:SELECT airs.trip_type AS trip_type,   总和(airs.total_including ...                                               ^提示:没有函数匹配给定的名称和参数类型。您可能需要添加   显式类型转换。 'SELECT airs.trip_type AS trip_type,   sum(airs.total_including_tax)AS total \ nFROM播放GROUP BY   airs.trip_type'{}

CODE:

model.py
from datetime import datetime
import hashlib
from sqlalchemy.inspection import _self_inspects
from werkzeug.security import generate_password_hash, check_password_hash
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from markdown import markdown
import bleach
from flask import current_app, request, url_for
from flask.ext.login import UserMixin, AnonymousUserMixin
from app.exceptions import ValidationError
from . import db, login_manager

class Air(db.Model):
    __tablename__ = 'airs'
    id = db.Column(db.Integer, primary_key=True)
    booking_reference = db.Column(db.Integer) #, unique=True)
    company_name = db.Column(db.Unicode)
    trip_type = db.Column(db.Unicode)
    total_including_tax = db.Column(db.Unicode)

importer.py
    query =    db.session.query(Air.trip_type.label('trip_type'), func.sum(Air.total_including_tax).label("total")).group_by(Air.trip_type)

0 个答案:

没有答案