예제 #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
파일: views.py 프로젝트: ThreerEyed/flask_1
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
파일: views.py 프로젝트: xzlmark/flask
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
파일: views.py 프로젝트: xlyul/flask-
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 '创建成功'