sqlalchemy转储在哪里是manage.py

时间:2017-05-27 22:35:18

标签: python python-2.7 sqlalchemy flask-sqlalchemy

我试图让alchemydumps备份我的数据库,并在尝试运行alchemydumps create命令时收到以下错误。我认为这是由多对多关系错误引起的,但我不确定。

intermediates

Alchemy dumps documents

manage.py

 File "/home/jsnyder10/Documents/45/flask/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3971, in __init__
"expected - got '%r'" % (column, )
sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity expected - got '<class 'flask_sqlalchemy.Model'>'

回溯:

from flask import Flask
from flask_alchemydumps import AlchemyDumps, AlchemyDumpsCommand
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy

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


# init Flask
app = Flask(__name__)

#SQL Alchemy Database config location
if os.environ.get('DATABASE_URL') is None:
    SQLALCHEMY_DATABASE_URI = ('sqlite:///' + os.path.join(basedir, 'app.db') +
                               '?check_same_thread=False')
else:
    SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']


# init SQLAlchemy and Flask-Script
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
manager = Manager(app)

@manager.command
def hello():
    print "hello"

# init Alchemy Dumps
alchemydumps = AlchemyDumps(app, db)
manager.add_command('alchemydumps', AlchemyDumpsCommand)

if __name__ == "__main__":
    manager.run()

0 个答案:

没有答案