def create_db(): """ 创建数据库 :return: """ db.create_all() return "create DB sccuessful"
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
def create_db(): """ 创建数据库数据 :return: """ db.create_all() return "数据库创建成功"
def create_db(): """ 初始建表 :return: """ db.create_all() db.session.commit() return '创建成功'
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
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!")
def create_db(): db.create_all() return '<h2>Aleady Create_table</h2>'
def create_db2(): db.create_all() return "create DB sccuessful"
def create_db(): """ 创建数据 """ db.create_all() return '创建成功'
def createdb(): db.create_all() return '创建数据表成功'
def addUser(): db.create_all() return '创建成功'
def create_db_user(): db.create_all() return '创建成功'
def create_table(): db.create_all() return '创建成功'
def create_db(): db.create_all() return '成功创建数据'
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
def createTable(): db.create_all() return '创建表成功'
def create_db(): db.create_all()
def db_create(): db.create_all() return "创建表"
def create_db(): db.create_all() return 'DB Create Success'
def createdb(): db.create_all() #db.drop_all() return 'success'
def crate_db(): db.create_all() return '数据库创建成功'
def initDB(): #db.drop_all(app=app) db.create_all(app=app) print('database initialized!')
from App.models import db from App.views import app db.create_all() app.run(debug=True)
def create(): db.create_all() return "创建成功"
def create_user(): a = db.create_all() return '创建成功'
def create_db(): db.create_all() return '创建数据库成功!'
def create_db(): '''创建数据库''' db.create_all() return '创建成功'
def create_db(): db.create_all() db.session.commit() return '创建成功'
def create_db(): db.create_all() return '创建成功'
def create_database(): db.create_all() return '创建成功'