Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

google 了 3 天反复测试也找不到答案的 Flask-SQLAlchemy 问题,请拯救我于水火 a men

求教各位大佬:
订单表( FuckOrders )的 diy_order_phoneShellID 字段,对应 商品型号表( PhonesShell )的 phoneShellID 字段。
商品型号表有一个 phoneShellDesc 商品型号描述字段。
对应的 sql 语句是
select * from diy_orders o
INNER JOIN diy_phone_shells s
on o.diy_order_phoneShellID=s.phoneShellID
where diy_order_status=2
ORDER BY o.createDateObj DESC
我想把订单表中每个订单所对应的 phoneShellDesc 字段显示到网页中。
请问上面的语句应该怎么样改呢? 谢谢指点
py 文件代码:

from flask import Flask, request, flash, url_for, redirect, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:[email protected]:3306/diy'
app.config['SECRET_KEY'] = "random string"
db = SQLAlchemy(app)
class FuckOrders(db.Model):
__tablename__ = 'diy_orders'
#id = db.Column('diy_order_id', db.Integer, primary_key = True)
diy_order_id = db.Column(db.Integer, primary_key = True)
diy_order_receiver = db.Column()
diy_order_phone = db.Column()
diy_order_province= db.Column()
diy_order_city = db.Column()
diy_order_area = db.Column()
diy_order_detail= db.Column()
diy_order_status= db.Column()
diy_order_count = db.Column()
diy_order_phoneShellID=db.Column()
diy_order_orderDealMoneyFen=db.Column()
diy_order_renderImgUrl= db.Column()
diy_order_renderImgWithShellUrl= db.Column()
createDateObj= db.Column()
diy_order_ship= db.Column()
#phoneShellDesc 这个是否需要声明?
def __init__(self, diy_order_receiver, diy_order_phone,diy_order_city, diy_order_area,diy_order_count,diy_order_detail,diy_order_status,diy_order_orderDealMoneyFen,diy_order_phoneShellID,diy_order_renderImgUrl,diy_order_renderImgWithShellUrl,createDateObj,diy_order_ship,diy_order_phoneShellDESC):
self.diy_order_receiver = diy_order_receiver
self.diy_order_phone = diy_order_phone
self.diy_order_city = diy_order_city
self.diy_order_area = diy_order_area
self.diy_order_count = diy_order_count
self.diy_order_detail= diy_order_detail
self.diy_order_status=diy_order_status
self.diy_order_phoneShellID=diy_order_phoneShellID
self.diy_order_orderDealMoneyFen=diy_order_orderDealMoneyFen
self.diy_order_renderImgUrl=diy_order_renderImgUrl
self.diy_order_renderImgWithShellUrl=diy_order_renderImgWithShellUrl
self.createDateObj=createDateObj
self.diy_order_ship=diy_order_ship
self.diy_order_phoneShellDESC=diy_order_phoneShellDESC
class PhonesShell(db.Model):
__tablename__ = 'diy_phone_shells'
id = db.Column('phoneShellKeyId', db.Integer, primary_key = True)
phoneShellID = db.Column(db.Integer)
phoneShellDesc = db.Column(db.String)

def __init__(self, phoneShellID,phoneShellDesc):
self.phoneShellID = phoneShellID
self.phoneShellDesc = phoneShellDesc

@app.route('/')
def Show_Orders()
return render_template('Order_Lists.html',HiOrders=FuckOrders.query.outerjoin(PhonesShell, PhonesShell.phoneShellID==FuckOrders.diy_order_phoneShellID).all())
if __name__ == '__main__':
app.run(debug = True)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...