flask怎样查询mysql并显示在页面上
1个回答
展开全部
flask怎样查询mysql并显示在页面上
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Database(object):
def __init__(self, configure):
self.configure = configure
self.engine = create_engine(self.configure.MYSQL_SQLALCHEMY_URL)
self.Session = sessionmaker(bind=self.engine)
self.session = self.Session()
from sqlalchemy import Column, Integer, String, Sequence
class User(Base):
"""
user table
"""
__tablename__ = 'user'
id = Column(Integer, Sequence("USER_ID_SEQ"), primary_key=True)
username = Column(String(256), doc=u"用户名")
password = Column(String(256), doc=u"密码")
def __repr__(self):
return "<User(username='%s', password='%s', id='%s')" % (self.username, self.password, self.id)
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Database(object):
def __init__(self, configure):
self.configure = configure
self.engine = create_engine(self.configure.MYSQL_SQLALCHEMY_URL)
self.Session = sessionmaker(bind=self.engine)
self.session = self.Session()
from sqlalchemy import Column, Integer, String, Sequence
class User(Base):
"""
user table
"""
__tablename__ = 'user'
id = Column(Integer, Sequence("USER_ID_SEQ"), primary_key=True)
username = Column(String(256), doc=u"用户名")
password = Column(String(256), doc=u"密码")
def __repr__(self):
return "<User(username='%s', password='%s', id='%s')" % (self.username, self.password, self.id)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询