Пример #1
0
def create_db():
    """
    创建数据库
    :return:
    """
    db.create_all()
    return "create DB sccuessful"
Пример #2
0
def create_app():
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    static_dir = os.path.join(BASE_DIR, 'static')
    templates_dir = os.path.join(BASE_DIR, 'templates')

    app = Flask(__name__,
                static_folder=static_dir,
                template_folder=templates_dir)
    app.register_blueprint(blueprint=admin, url_prefix='/user')




    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]:3306/flaskstudent'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    # 如果设置成True(默认情况),Flask-SQLAlchemy 将会追踪对象的修改并且发送信号。这需要额外的内存, 如果不必要的可以禁用它

    # 设置session密钥
    app.config['SECRET_KEY'] = 'secret_key'

    db.init_app(app=app)
    with app.app_context():
        # db.drop_all()
        db.create_all()

    return app
Пример #3
0
def create_db():
    """
    创建数据库数据
    :return:
    """
    db.create_all()
    return "数据库创建成功"
Пример #4
0
def create_db():
    """
    初始建表
    :return:
    """
    db.create_all()
    db.session.commit()
    return '创建成功'
Пример #5
0
def create_app():
    app = Flask(__name__, static_url_path='/static')
    loadConfig(app)
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.config['PREFERRED_URL_SCHEME'] = 'https'
    app.config['UPLOADED_PHOTOS_DEST'] = "App/uploads"
    photos = UploadSet('photos', TEXT + DOCUMENTS + IMAGES)
    configure_uploads(app, photos)
    db.init_app(app)
    login_manager.init_app(app)
    db.create_all(app=app)
    return app
Пример #6
0
def initDB():
    db.create_all(app=app)

    # add code to parse csv, create and save room objects
    with open("App/rooms.csv", "r") as csv_file:
        data = csv.DictReader(csv_file)

        for row in data:
            room = Room(roomType=row["type"],
                        roomRate=row["roomRate"],
                        roomNumber=row["roomNumber"])

            try:
                db.session.add(room)
                db.session.commit()

            except IntegrityError:
                db.session.rollback()
                print("\n\nRoom Already Exists\n\n")

    make_users()
    print("Database Initialized!")
Пример #7
0
def create_db():
    db.create_all()
    return '<h2>Aleady Create_table</h2>'
Пример #8
0
def create_db2():
    db.create_all()
    return "create DB sccuessful"
Пример #9
0
def create_db():
    """
    创建数据
    """
    db.create_all()
    return '创建成功'
Пример #10
0
def createdb():
    db.create_all()
    return '创建数据表成功'
Пример #11
0
def addUser():
    db.create_all()

    return '创建成功'
Пример #12
0
def create_db_user():
    db.create_all()
    return '创建成功'
Пример #13
0
def create_table():
    db.create_all()
    return '创建成功'
Пример #14
0
def create_db():
    db.create_all()
    return '成功创建数据'
Пример #15
0
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'


def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
    app.config['SECRET_KEY'] = "MYSECRET"
    app.config['JWT_EXPIRATION_DELTA'] = timedelta(days=7)
    db.init_app(app)
    return app


app = create_app()

app.app_context().push()
db.create_all(app=app)

app.register_blueprint(api_views)
app.register_blueprint(user_views)
''' Set up JWT here (if using flask JWT)'''


def authenticate(username, password):
    #search for the specified user
    user = User.query.filter_by(email=username).first()
    #if user is found and password matches
    if user and user.check_password(password):
        return user


#Payload is a dictionary which is passed to the function by Flask JWT
Пример #16
0
def createTable():
    db.create_all()
    return '创建表成功'
Пример #17
0
def create_db():
	db.create_all()
Пример #18
0
def db_create():
    db.create_all()
    return "创建表"
Пример #19
0
def create_db():
    db.create_all()
    return 'DB Create Success'
Пример #20
0
def createdb():
    db.create_all()
    #db.drop_all()
    return 'success'
Пример #21
0
def crate_db():
    db.create_all()
    return '数据库创建成功'
Пример #22
0
def initDB():
    #db.drop_all(app=app)
    db.create_all(app=app)
    print('database initialized!')
Пример #23
0
from App.models import db
from App.views import app
db.create_all()
app.run(debug=True)
Пример #24
0
def create():
    db.create_all()
    return "创建成功"
Пример #25
0
def create_user():
    a = db.create_all()

    return '创建成功'
Пример #26
0
def create_db():
    db.create_all()
    return '创建数据库成功!'
Пример #27
0
def create_db():
    '''创建数据库'''
    db.create_all()
    return '创建成功'
Пример #28
0
def create_db():
    db.create_all()
    db.session.commit()
    return '创建成功'
Пример #29
0
def create_db():

    db.create_all()
    return '创建成功'
Пример #30
0
def create_database():
    db.create_all()
    return '创建成功'