带有mysql的Flask RESTFUL OperationalError:(sqlite3.OperationalError)

时间:2016-04-20 08:30:09

标签: python mysql apache rest flask

我的python flask-restful app有问题。我正在使用apache在EC2 Amazon上部署我的应用程序,但是当我正在尝试连接到我的api a" 500内部服务器错误"出现

OperationalError: (sqlite3.OperationalError) no such table: employee

我不明白,因为我使用mysql连接并使用mysqlWorkBench测试与数据库的连接

run.py

from flask import Flask
from flask.ext.restful import Api
from flask_restful.utils import cors
from src.resources.manageApp import addConfig, addBlueprints

app = Flask(__name__)
api = Api(app)
api.decorators = [cors.crossdomain(origin='*', headers=['accept', 'Content-Type'])]

addConfig()
addBlueprints()

addConfig函数

from src.common.app import app

app.config.from_object('src.common.config')

config.py

import os

basedir = os.path.abspath(os.path.dirname(__file__))

DEBUG = True

ApiBaseUrl = '/api/'

ApiVersion = 'v1.1'

SQLALCHEMY_DATABASE_URI = 'mysql://user:password@db.domain.com:3306/clipse'

SQLALCHEMY_TRACK_MODIFICATIONS = True

api.wsgi

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/clipse/Api/")

from deploy.run import app as application
application.config.from_object('src.common.config')

数据库

table employee

1 个答案:

答案 0 :(得分:0)

谢谢我解决了我的问题我在api.wsgi中使用我的main.py来输入你的权利我没有加载相同的实例

main.py

import sys
from src.resources.manageApp import addConfig, addBlueprints, app
from src.resources.db import db
from src.common import config

addConfig()
addBlueprints()

def main():
  ...
  app.run(host='0.0.0.0')

if __name__ == '__main__':
  main()

和我的api.wsgi

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/api/")

from main import app as application

THX度过了愉快的一天:)