提交 aab9f9f2 编写于 作者: X xj.lin

Merge branch 'develop' into linxj

.idea/
.ycm_extra_conf.py
__pycache__
.env
......@@ -2,12 +2,15 @@
### Geting started
- Create .env base on .env.example
- Install Miniconda first
- `conda create --name vec_engine python=3.6`
- `conda activate vec_engine`
- `conda install faiss-gpu cuda90 -c pytorch # For CUDA9.0`
- `conda install flask`
- `pip install flask-restful flask_sqlalchemy`
- `pip install flask-restful flask_sqlalchemy flask_script`
- `pip install pymysql environs`
### Create Database
......
DEBUG=True
SQLALCHEMY_TRACK_MODIFICATIONS=False
SECRET_KEY=test
SQLALCHEMY_DATABASE_URI=mysql+pymysql://vecwise@127.0.0.1:3306/vecdata
ROW_LIMIT=10000000
DATABASE_DIRECTORY=/tmp
# -*- coding: utf-8 -*-
from engine import settings
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
print ("Load paramters")
app = Flask(__name__)
app.config.from_object('engine.settings')
app.config.from_object(settings)
#创建数据库对象
print ("Create database instance")
......
# _*_ coding: utf-8 _*_
from environs import Env
DEBUG = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
# SECRET_KEY='A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://vecwise@127.0.0.1:3306/vecdata"
env = Env()
env.read_env()
ROW_LIMIT = 1000000
DATABASE_DIRECTORY = '/tmp'
\ No newline at end of file
DEBUG = env.bool('DEBUG', default=False)
SQLALCHEMY_TRACK_MODIFICATIONS = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', 'test')
SQLALCHEMY_DATABASE_URI = env.str('SQLALCHEMY_DATABASE_URI')
ROW_LIMIT = env.int('ROW_LIMIT')
DATABASE_DIRECTORY = env.str('DATABASE_DIRECTORY')
from flask_script import Manager
from engine import db, app
manager = Manager(app)
@manager.command
def create_all():
db.create_all()
@manager.command
def drop_all():
db.drop_all()
@manager.command
def recreate_all():
db.drop_all()
db.create_all()
if __name__ == '__main__':
manager.run()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册