diff --git a/flask_peewee/db.py b/flask_peewee/db.py index 3cfccce..5065aa6 100644 --- a/flask_peewee/db.py +++ b/flask_peewee/db.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + import peewee from peewee import * @@ -6,7 +9,11 @@ class Database(object): - def __init__(self, app): + def __init__(self, app=None): + if app: + self.init_db(app) + + def init_app(self, app): self.app = app self.load_database() @@ -14,6 +21,7 @@ def __init__(self, app): self.Model = self.get_model_class() + def load_database(self): self.database_config = dict(self.app.config['DATABASE']) try: