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