Add model

pull/3/head
jinhai 2019-03-19 21:04:27 +08:00
parent 9354c0384d
commit 577ee06710
7 changed files with 44 additions and 3 deletions

View File

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
print ("Load paramters")
app = Flask(__name__)
app.config.from_object('engine.settings')
#创建数据库对象
print ("Create database instance")
db = SQLAlchemy(app)
from engine.model.IndexTable import IndexTable
from engine.controller import IndexManage

View File

@ -1,7 +1,8 @@
from flask import Flask
from flask_restful import Resource, Api
from engine import app, db
app = Flask(__name__)
# app = Flask(__name__)
api = Api(app)
@ -64,5 +65,5 @@ api.add_resource(Index, '/vector/index')
api.add_resource(VectorSearch, '/vector/search')
if __name__ == '__main__':
app.run(debug=True)
# if __name__ == '__main__':
# app.run()

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,16 @@
from engine import db
class IndexTable(db.Model):
__tablename__ = 'index_table'
id = db.Column(db.Integer, primary_key=True)
tablename = db.Column(db.String(100))
filename = db.Column(db.String(100))
type = (db.Integer)
def __init__(self, tablename, filename, type):
self.tablename = tablename
self.filename = filename
self.type = type
def __repr__(self):
return '<IndexTable $r>' % self.tablename

View File

@ -0,0 +1,6 @@
# _*_ coding: utf-8 _*_
DEBUG = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY='A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
SQLALCHEMY_DATABASE_URI = "mysql://user:passwd@ip:port/BLOG_DB"

2
pyengine/runserver.py Normal file
View File

@ -0,0 +1,2 @@
from engine import app
app.run()