def create_db():
    """
    Custom flask db command to create all tables from models
    """

    db.create_all()
    print("TABLES CREATED")
Example #2
0
    def setUp(self):
        self.app = create_app(config_name='testing')
        self.client = self.app.test_client()

        with self.app.app_context():
            print('\n---- Create databases ----\n')
            db.create_all()
    def setUp(cls):
        cls.app = create_app()
        cls.app_context = cls.app.app_context()
        cls.app_context.push()
        cls.client = cls.app.test_client()

        db.create_all()
        runner = cls.app.test_cli_runner()
        runner.invoke(args=["db-custom", "seed"])
Example #4
0
def make_sure_there_is_a_working_database(*args, **kwargs):
    if current_app.config.get('ENV') != 'dev':
        return
    inspector = Inspector.from_engine(db.engine)
    tables = inspector.get_table_names()
    required_tables = [models.PDFForm.__tablename__]
    if not (set(required_tables) < set(tables)):
        current_app.logger.warning(
            "database tables {} not found. Creating tables".format(required_tables))
        db.create_all()
Example #5
0
def make_sure_there_is_a_working_database(*args, **kwargs):
    if current_app.config.get('ENV') != 'dev':
        return
    inspector = Inspector.from_engine(db.engine)
    tables = inspector.get_table_names()
    required_tables = [models.PDFForm.__tablename__]
    if not (set(required_tables) < set(tables)):
        current_app.logger.warning(
            "database tables {} not found. Creating tables".format(required_tables))
        db.create_all()
Example #6
0
    def setUpClass(cls):
        if os.environ.get("FLASK_ENV") != "workflow":
            os.environ["FLASK_ENV"] = "testing"
        else:
            os.environ[
                "DB_TEST_URI"] = "postgresql+psycopg2://postgres:postgres@localhost:5432/poketeams_test"
        cls.app = create_app()
        cls.app_context = cls.app.app_context()
        cls.app_context.push()
        cls.context = cls.app.test_request_context()
        cls.context.push()
        cls.client = cls.app.test_client()

        db.create_all()
        runner = cls.app.test_cli_runner()
        runner.invoke(args=["db-custom", "seed"])
Example #7
0
def migrate():
    db.drop_all()
    db.create_all()
    db.session.commit()
Example #8
0
 def setUp(self):
     FlaskTestCase.setUp(self)
     db.create_all()
Example #9
0
#!/usr/bin/env python

# from src.main import db
import time
import datetime
from src.main import db
from src.models.audit_log import TbCreditLog
from src.models.user import (
    TbMerchantCredit, TbMerchant, TbProduction,
)


if __name__ == '__main__':
    db.create_all()
    merchant = TbMerchant()
    merchant.name = "阳泉商行"
    merchant.create_time = datetime.datetime.now()
    merchant.is_active = True
    merchant.org_no = '1111'
    merchant.code = '2222'
    db.session.add(merchant)
    db.session.commit()

    # merchant.save()
    production = TbProduction()
    production.merchant_id = merchant.id
    production.name = '泉涌贷'
    production.code = '111'
    production.status = True
    db.session.add(production)
    db.session.commit()
Example #10
0
 def setUp(self):
     db.create_all()
     db.session.commit()
Example #11
0
 def setUp(self):
     FlaskTestCase.setUp(self)
     db.create_all()