Merge branch 'develop' into linxj

pull/3/head
xj.lin 2019-03-27 19:39:11 +08:00
commit aab9f9f287
6 changed files with 48 additions and 10 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
.idea/
.ycm_extra_conf.py
__pycache__
.env

View File

@ -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

View File

@ -0,0 +1,7 @@
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

View File

@ -1,10 +1,10 @@
# -*- 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")

View File

@ -1,9 +1,12 @@
# _*_ 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'
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')

21
pyengine/manager.py Normal file
View File

@ -0,0 +1,21 @@
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()