Move db in model.
This commit is contained in:
parent
7822550b79
commit
c5147feee8
@ -22,7 +22,8 @@ from flask_alembic import Alembic
|
||||
from flask_alembic.cli.click import cli as alembic_cli
|
||||
from flask_restplus import Api
|
||||
from flask_cors import CORS
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
from .models import db
|
||||
|
||||
# The app
|
||||
app = Flask(__name__, static_folder=None, template_folder=None)
|
||||
@ -34,8 +35,7 @@ app.config['SQLALCHEMY_ECHO'] = app.debug
|
||||
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
|
||||
|
||||
# Database initialization.
|
||||
db = SQLAlchemy(app)
|
||||
db.init_app(app)
|
||||
|
||||
# Database migrations.
|
||||
alembic = Alembic(app)
|
||||
|
@ -16,7 +16,12 @@
|
||||
"""
|
||||
import pkgutil
|
||||
|
||||
__all__ = []
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
db = SQLAlchemy()
|
||||
|
||||
__all__ = ['db']
|
||||
|
||||
for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
|
||||
__all__.append(module_name)
|
||||
|
@ -14,7 +14,8 @@
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from accountant import db
|
||||
# pylint: disable=no-member,too-few-public-methods
|
||||
from . import db
|
||||
|
||||
from .operations import Operation
|
||||
|
||||
|
@ -18,7 +18,8 @@ from datetime import date
|
||||
|
||||
import arrow
|
||||
|
||||
from accountant import db
|
||||
# pylint: disable=no-member,too-few-public-methods
|
||||
from . import db
|
||||
|
||||
|
||||
class Operation(db.Model):
|
||||
|
@ -18,7 +18,8 @@ from calendar import monthrange
|
||||
|
||||
import arrow
|
||||
|
||||
from accountant import db
|
||||
# pylint: disable=no-member,too-few-public-methods,too-many-instance-attributes
|
||||
from . import db
|
||||
|
||||
from .accounts import Account
|
||||
from .operations import Operation
|
||||
|
@ -23,7 +23,8 @@ from flask import current_app as app
|
||||
|
||||
from flask_login import UserMixin
|
||||
|
||||
from accountant import db
|
||||
# pylint: disable=no-member,too-few-public-methods
|
||||
from . import db
|
||||
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
|
Loading…
Reference in New Issue
Block a user