コード例 #1
0
ファイル: manage.py プロジェクト: marcusti/links
def clear_db():
    """Drops and creates all db tables. (DESTRUCTIVE)."""
    if prompt_bool("May I drop and re-create all database tables"):
        app.logger.info('dropping all tables...')
        db.drop_all()
        app.logger.info('creating all tables...')
        db.create_all()
コード例 #2
0
ファイル: manage.py プロジェクト: egeriicw/flask-bluebone
def initdb():
    """Init/reset database."""

    if not prompt_bool("Are you sure? You will lose all your data!"):
        return

    db.drop_all()
    db.create_all()

    demo = User(
            username=u'demo',
            email='*****@*****.**',
            password='******',
            role_id=USER,
            status_id=ACTIVE,
            user_detail=UserDetail(
                first_name=u'Demo',
                last_name=u'Dude',
                gender=u'female',
                dob=datetime.date(1985, 02, 17),
                phone=1234567890,
                bio=u'Demo dude is pretty sweet.',
                url=u'http://www.example.com/demo',
                ),
            )
コード例 #3
0
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(
        first_name=u"admin",
        last_name=u"admin",
        user_name=u"admin",
        password=u"123456",
        role_code=ADMIN,
        status_code=ACTIVE,
        user_settings=UserSettings(
            sex_code=MALE, age=10, phone="555-555-5555", bio=u"admin Guy is ... hmm ... just a admin guy."
        ),
    )
    email = Email(address="*****@*****.**", is_primary=True, status_code=VERIFIED)
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()

    hashtag = None
    """Add in all post hashtag"""
    for (key, id) in CATEGORIES.iteritems():
        hashtag = Hashtag(id=id, name=key)
        db.session.add(hashtag)
    db.session.commit()

    # generate 1000 random post
    """
    for x in range(0,1000):
      post = Post(name='test-'+str(x), price=10, description='AOH LALAL')
      post.user_id = admin.id
      post.add_hashtag(hashtag)
      db.session.add(post)
   
      db.session.commit()

      chat = Chat(buyer= admin)
      msg = ChatMessage(body = "TEST MESSAGE", created_by = admin.id)
      post.add_chat(chat)
      chat.add_message(msg)
      db.session.commit()

    db.session.commit()
    """

    # Add in ucla circle
    ucla = Circle(name=u"ucla", description=u"ucla.edu emails only")
    ucla.add_member(admin)
    db.session.add(ucla)
    db.session.commit()

    ucla_info = CollegeInfo(
        circle_id=ucla.id, domain=u"ucla.edu", fb_group_id=267279833349705, fb_sell_id=267375200006835
    )
    db.session.add(ucla_info)
    db.session.commit()
コード例 #4
0
ファイル: views.py プロジェクト: sancayouth/DynTablesPy
def add():
    form = DynTableForm()
    detail_form = DynAttributeForm()
    rform = request.form
    if form.validate_on_submit():
        dyn_table = DynTable(rform.get('id_'))
        db.session.add(dyn_table)
        if len(rform) > 2:
            #add detail
            attr_list = []
            for i in range(1, len(rform) - 1):
                attr_dic = formToDict(rform.get('attr_' + str(i)))
                print attr_dic
                attr = DynAttribute(
                    attr_dic.get('attr_name').replace('+', ' '), dyn_table.id,
                    attr_dic.get('display', '').replace('+', ' '),
                    attr_dic.get('attr_type')[0], 'pk' in attr_dic,
                    'required' in attr_dic)
                attr_list.append(attr_dic)
                db.session.add(attr)
        db.session.commit()
        create_table(rform.get('id_'), attr_list)
        db.create_all()
        #should create the table on DB
        return '1'
    return render_template('index.html', title='DynTable - Add Table',
                           form=form, detail_form=detail_form, url='add')
コード例 #5
0
    def setup(self, app):
        self.db_bind = 'jitmeet'
        mydbplugindir = os.path.join(app.config['BASEDIR'],'app/plugins/jitmeet/db/jitmeet.db')
        app.config['SQLALCHEMY_BINDS'].update({self.db_bind : 'sqlite:///%s' % mydbplugindir})

        with app.app_context():
            db.create_all(bind=self.db_bind)
コード例 #6
0
def db(app, request):
    _db.app = app
    _db.create_all()

    yield _db

    _db.drop_all()
    os.unlink(TESTDB_PATH)
コード例 #7
0
def flask_app():
    app = create_app(flask_config='testing')
    from app.extensions import db

    with app.app_context():
        db.create_all()
        yield app
        db.drop_all()
コード例 #8
0
ファイル: run.py プロジェクト: sboily/xivo-unified
def resetdb():
    """Init/reset database."""

    if not prompt_bool("Are you sure? You will lose all your data!"):
        return

    db.drop_all()
    db.create_all()
    db.session.commit()
コード例 #9
0
def create_app(config=TestConfig):
    app = Flask(__name__)
    app.config.from_object(config)
    app.url_map.strict_slashes = False
    register_extensions(app)
    register_blueprints(app)

    from app.extensions import db
    db.create_all(app=app)
    return app
コード例 #10
0
def _db(app):
    """Special fixture for pytest-flask-sqlalchemy.

    The pytest-flask-sqlalchemy provides `db_session` to be used in
    tests.
    That fixture automatically handles transactions - the data created
    during the test, will be removed from the database after the test.
    """
    db.create_all()
    return db
コード例 #11
0
ファイル: cli.py プロジェクト: maikeulb/filmogram
    def seed():
        print('Starting DB seed')
        db.drop_all()
        db.create_all()

        seed_users()
        seed_posts()

        db.session.commit()
        print('DB seed complete')
コード例 #12
0
ファイル: conftest.py プロジェクト: simon-norman/api-tab-tidy
def test_client(test_app):
    context = test_app.app_context()
    context.push()

    db.drop_all()
    db.create_all()

    yield test_app.test_client()

    context.pop()
コード例 #13
0
ファイル: __init__.py プロジェクト: yairs0117/JobCenter
 def initdb(drop):
     """Initialize the database."""
     if drop:
         click.confirm(
             'This operation will delete the database, do you want to continue?',
             abort=True)
         db.drop_all()
         click.echo('Drop tables.')
     db.create_all()
     click.echo('Initialized database.')
コード例 #14
0
def db(app):
    """Session-wide test database."""

    _db.app = app
    _db.session.remove()
    _db.create_all()

    yield _db

    _db.drop_all()
コード例 #15
0
ファイル: manage.py プロジェクト: marcusti/links
def import_db_from_json():
    """Imports a collection of links from a 'db.json' file (DESTRUCTIVE)."""
    app.logger.info(app.config.get('SQLALCHEMY_DATABASE_URI'))
    with open('db.json') as f:
        if prompt_bool("May I import links from 'db.json'"):
            app.logger.info('dropping all tables...')
            db.drop_all()
            app.logger.info('creating all tables...')
            db.create_all()

            content = json.load(f)

            app.logger.info('importing users...')
            if 'users' in content:
                for u in content['users']:
                    user = User(email=u['email'])
                    g.user = user
                    user.locale = u.get('locale', '')
                    user.timezone = u.get('timezone', '')
                    user.is_active = u.get('is_active', True)
                    db.session.add(user)
                db.session.commit()

            app.logger.info('importing tags...')
            tags = []
            for t in content.get('links', []):
                tagname = t.get('tag', '')
                if not tagname in tags:
                    tags.append(tagname)
            for tagname in tags:
                tag = Tag.query.filter_by(name=tagname).first()
                if tag is None:
                    try:
                        tag = Tag(name=tagname)
                        db.session.add(tag)
                    except Exception, e:
                        app.logger.error('error creating tag "%s"' % e)
                        continue
            db.session.commit()

            app.logger.info('importing bookmarks...')
            for l in content.get('links', []):
                link = Bookmark(name=l['name'], url=l['url'])
                link.menu = l.get('menu', None)
                link.public = l.get('public', False)
                link.clicks = l.get('clicks', 0)
                if 'user_email' in l:
                    user = User.query.filter_by(email=l['user_email']).first()
                    link.user_id = user.id
                # for tagname in l.get('tags', []):
                tagname = l.get('tag', '')
                tag = Tag.query.filter_by(name=tagname).first()
                link.tags.append(tag)
                db.session.add(link)
            db.session.commit()
コード例 #16
0
ファイル: manage.py プロジェクト: sancayouth/Flask-SiteLyrics
def adduser(email, username):
    from getpass import getpass
    password = getpass()
    password2 = getpass(prompt='Confirm: ')
    if password != password2:
        import sys
        sys.exit('Error: passwords do not match.')
    db.create_all()
    user = User(email=email, username=username, password=password)
    db.session.add(user)
    db.session.commit()
コード例 #17
0
def db(app):
    """
    Test database table creation and cleanup per test session
    """
    _db.app = app
    _db.create_all()
    yield _db
    # proposed drop_all fix for postgres by Mike Bayer
    # http://jrheard.tumblr.com/post/12759432733/dropping-all-tables-on-postgres-using
    _db.reflect()
    _db.drop_all()
コード例 #18
0
ファイル: init_db.py プロジェクト: Wiredcraft/gh-report
def init_db():
    """ Clean up and create database. """

    app = Flask(__name__)
    load_config(app)

    db.init_app(app)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'app.sqlite')
    with app.app_context():
        db.drop_all()
        db.create_all()
コード例 #19
0
 def setUp(self):
     """Create application instance and insert necessary
     information into the database before each test.
     """
     self.app = create_app("testing", True)
     self.app_context = self.app.app_context()
     self.app_context.push()
     self.search_middleware = self.app.sqlalchemy_search_middleware
     db.create_all()
     Event.__tablename__ = "testing_index"
     Event.__doctype__ = "testing"
コード例 #20
0
ファイル: __init__.py プロジェクト: barry-ran/TaskScheduler
    def init():
        """Initialize Albumy."""
        click.echo('Initializing the database...')
        db.create_all()

        #click.echo('Initializing the roles and permissions...')
        Role.insert_roles()
        click.echo('Done.')

        User.create_root()
        click.echo('Create root user.')
コード例 #21
0
def test():
    """
    This function run test from shell by command:
    'flask test'
    """
    import unittest
    tests = unittest.TestLoader().discover('tests')
    db.create_all()
    results = unittest.TextTestRunner(verbosity=2).run(tests)
    ret = not results.wasSuccessful()
    sys.exit(ret)
コード例 #22
0
ファイル: __init__.py プロジェクト: huxaiphaer/travel_huxy
 def setUp(self):
     db.create_all()
     weather = WeatherForecast(weather_type="Sunny",
                               date_time=datetime(2012, 3, 3, 10, 10, 10),
                               description="Its sunny",
                               name="Sunny ",
                               latitude="34.790878",
                               longitude="48.570728")
     db.session.add(weather)
     db.session.commit()
     self.client = application.test_client(self)
コード例 #23
0
 def initdb(drop):
     if drop:
         click.confirm('这个操作会删除你的数据库,确定吗?', abort=True)
         db.drop_all()
         click.echo('删除数据表')
     db.create_all()
     user = User(username='******')
     user.set_password('123456')
     db.session.add(user)
     db.session.commit()
     click.echo('初始化数据库')
コード例 #24
0
def init_db():
    """
    Flask command to create the database schemas.

    Use this when you are running your service for the 1st time,
    after editing db connection logic. This will drop the table,
    and rebuild it
    """
    db.drop_all()
    db.create_all()
    db.session.commit()
コード例 #25
0
def app():
    app = create_app(config_name='test')

    with app.app_context():
        db.create_all()
        db.engine.execute(text(raw_sql))

        yield app

        db.drop_all()
        db.session.commit()
コード例 #26
0
def clear_db():
    if current_app.config['SQLALCHEMY_DATABASE_URI'].find('memory') != -1:
        db.create_all()
    user_items = models.User.query.all()
    pic_items = models.Picture.query.all()
    for item in user_items:
        db.session.delete(item)
    db.session.commit()
    for item in pic_items:
        db.session.delete(item)
    db.session.commit()
コード例 #27
0
def create_app(config_object=ProdConfig):
    app = Flask(__name__)
    app.config.from_object(config_object)
    register_extensions(app)
    register_blueprints(app)
    register_error_handlers(app)
    setup_logging(app)
    if config_object.DEBUG:
        with app.app_context():
            db.create_all()
    return app
コード例 #28
0
def initdb():
    db.drop_all(bind=None)
    db.create_all(bind=None)

    user = models.User(first_name=u'Sam',
                       last_name=u'Chuang',
                       user_name=u'spchuang',
                       password=u'123456',
                       email=u"*****@*****.**")
    db.session.add(user)
    db.session.commit()
コード例 #29
0
def db(app):
    """A database for testing."""

    _db.app = app
    with app.app_context():
        _db.create_all()

    yield _db

    _db.session.close()
    _db.drop_all()
コード例 #30
0
    def seed():
        print('Starting DB seed')
        # db.drop_all()
        db.create_all()

        seed_users()
        seed_categories()
        seed_catalog()

        db.session.commit()
        print('DB seed complete')
コード例 #31
0
def init():
    """
    Initialize the database.

    :param with_testdb: Create a test database
    :return: None
    """
    db.drop_all()
    db.create_all()

    return None
コード例 #32
0
    def setUp(self):
        """Create application instance and insert necessary
        information into the database before each test.
        """

        self.app = create_app("testing", False)
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client()
コード例 #33
0
def test_db(test_app):  # pylint: disable=redefined-outer-name
    """
    test db fixture
    """
    # with app context
    with test_app.app_context():
        # create database tables
        db.create_all()
        # yield session
        yield db
        # drop all tables created
        db.drop_all()
コード例 #34
0
 def dropdb():
     """
     清空数据表
     """
     click.confirm(
         'This operation will delete the database, do you want to continue?',
         abort=True)
     db.drop_all()
     click.echo('Drop tables.')
     db.create_all()
     db.session.commit()
     click.echo('Initialized database.')
コード例 #35
0
def register_extensions(app):
    """Register Flask extensions."""

    db.init_app(app)

    with app.app_context():
        # Importing models for creation on application start
        # Could be removed when DB is already app & running
        from app.core.users import User

        # db.drop_all()
        db.create_all()
コード例 #36
0
    def init(drop):
        if drop:
            click.confirm('This operation will delete the database, are you sure to continue', abort=True)
            db.drop_all()
            click.echo('Drop tables')
        click.echo('Initializing database')
        db.create_all()

        click.echo('Initializing roles')
        Role.insert_roles()

        click.echo('Done.')
コード例 #37
0
def initdb():
    db.drop_all(bind=None)
    db.create_all(bind=None)

    # add sample user
    user = Models.User(first_name=u'Prem',
                       last_name=u'Narain',
                       user_name=u'Prem12',
                       password=u'123456',
                       email=u"*****@*****.**")
    db.session.add(user)
    db.session.commit()
コード例 #38
0
    def setUp(self):
        app = create_app('testing')
        self.context = app.test_request_context()
        self.context.push()
        self.client = app.test_client()
        self.runner = app.test_cli_runner()

        db.create_all()
        user = User(nickname='Tester', email="*****@*****.**")
        user.set_password('123456')
        db.session.add(user)
        db.session.commit()
コード例 #39
0
ファイル: run.py プロジェクト: zhuhj89/Mark
def createall():

    """Creates database tables
    """
    db.create_all()
    SQLALCHEMY_DATABASE_URI = current_app.config['SQLALCHEMY_DATABASE_URI']
    SQLALCHEMY_MIGRATE_REPO = current_app.config['SQLALCHEMY_MIGRATE_REPO']
    if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
        api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
コード例 #40
0
def create_app():
    app = Flask(__name__, static_folder="./static", template_folder="./static")
    app.config.from_pyfile('./app/config.py', silent=True)

    register_blueprint(app)
    register_extension(app)

    with app.app_context():
        print(db)
        db.create_all()
        db.session.commit()
    return app
コード例 #41
0
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('./app/config.py', silent=True)
    cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

    register_blueprint(app)
    register_extension(app)

    with app.app_context():
        db.create_all()
        db.session.commit()
    return app
コード例 #42
0
 def test_table_is_created(self):
     table_attr = []
     table_attr.append({"attr_name": "name", "attr_type": "S"})
     table_attr.append({"attr_name": "id", "attr_type": "I", "pk": True})
     Table = create_table("tablepoc", table_attr)
     db.create_all()
     poc = Table(id=1, name="hello")
     db.session.add(poc)
     db.session.commit()
     self.assertEqual(1, len(Table.query.all()))
     table = Table.query.first()
     self.assertEqual("hello", table.name)
     self.assertIsNotNone(db.metadata.tables.get("tablepoc"))
コード例 #43
0
def initdb():
    db.drop_all(bind=None)
    db.create_all(bind=None)

    # add sample user
    user = Models.User(
            first_name=u'Sam',
            last_name=u'Chuang',
            user_name=u'spchuang',
            password=u'123456',
            email=u"*****@*****.**") 
    db.session.add(user)
    db.session.commit()
コード例 #44
0
def flask_app():
    app = create_app()

    # use in-memory database
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
    app.config["TESTING"] = True
    app.config["WTF_CSRF_ENABLED"] = False
    app.config["SERVER_NAME"] = "sl.test"

    with app.app_context():
        db.create_all()

    yield app
コード例 #45
0
ファイル: manage.py プロジェクト: allanice001/microsnap
def initdb():
    "Reinitialise the database"
    db.drop_all(bind=None)
    db.create_all(bind=None)

    # add sample user
    user = Models.User(
        first_name=u'Admin',
        last_name=u'Root',
        user_name=u'admin',
        password=u'123456',
        email=u"*****@*****.**",
        role_code=1)
    db.session.add(user)
    db.session.commit()
コード例 #46
0
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(
            first_name=u'admin',
            last_name=u'admin',
            user_name=u'admin',
            password=u'gFcPU5XB',
            role_code=ADMIN,
            status_code=ACTIVE,
            user_settings=UserSettings(
                sex_code=MALE,
                age=10,
                phone='555-555-5555',
                bio=u''))
    email = Email(address= "*****@*****.**", is_primary=True, status_code=VERIFIED) 
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()
    
        
    hashtag = None
    """Add in all post hashtag"""
    for (key,id) in CATEGORIES.iteritems():
      hashtag = Hashtag(id=id, name = key)     
      db.session.add(hashtag)
    db.session.commit()
    
    #Add in ucla circle
    ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')  
    ucla.add_member(admin)
    db.session.add(ucla)   
    db.session.commit()
       
    ucla_info = CollegeInfo(circle_id = ucla.id, domain=u'ucla.edu',fb_group_id=267279833349705, fb_sell_id=267375200006835)
    db.session.add(ucla_info)
    db.session.commit()
コード例 #47
0
ファイル: app.py プロジェクト: pythonstory/rabiang-flask
 def initdb():
     """
     Initialize database setup.
     """
     db.drop_all()
     db.create_all()
コード例 #48
0
ファイル: tests.py プロジェクト: egeriicw/flask-bluebone
    def setUp(self):
        """Reset all tables before testing."""

        db.create_all()
        self.init_data()
コード例 #49
0
ファイル: test.py プロジェクト: guoylyy/JustGo_Project
def create_all():
    db.create_all()
    make_test_data()
コード例 #50
0
ファイル: manage.py プロジェクト: viaict/viaduct
def createdb():
    """Create a new empty database with a single administrator."""

    print("* Creating database schema")

    # Create the database schema
    db.create_all()

    print("* Adding alembic stamp")

    # Create alembic_version table
    migrations_directory = current_app.extensions['migrate'].directory
    config = alembic.config.Config(
        os.path.join(migrations_directory, 'alembic.ini'))
    config.set_main_option('script_location', migrations_directory)
    alembic.command.stamp(config, "head")

    # Add required groups
    print("* Adding administrators' and 'BC' groups")
    _add_group('administrators')
    _add_group('BC')

    # Add educations, which must be present to create the administrator user
    print("* Adding educations")
    education_names = [
        "BSc Informatica",
        "BSc Kunstmatige Intelligentie",
        "BSc Informatiekunde",
        "MSc Information Studies",
        "MSc Software Engineering",
        "MSc System and Network Engineering",
        "MSc Artificial Intelligence",
        "MSc Logic",
        "MSc Computational Science",
        "MSc Computer Science",
        "MSc Medical Informatics",
        "MSc Grid Computing",
        "Other",
        "Minor programmeren",
        "Minor Informatica",
        "Minor Kunstmatige Intelligentie"]

    for name in education_names:
        if not Education.query.filter(Education.name == name).first():
            db.session.add(Education(name=name))
        else:
            print("-> Education {} exists".format(name))
    db.session.commit()

    # Add some default navigation
    print("* Adding default navigation entries")
    navigation_entries = [
        ('via', 'via', '/via', False, [
            ('Nieuws', 'News', '/news/', False, []),
            ('PimPy', 'PimPy', '/pimpy', False, []),
            ('Commissies', 'Committees', '/commissie', False, []),
            ('Admin', 'Admin', '/admin', False, [
                ('Navigatie', 'Navigation', '/navigation', False, []),
                ('Formulieren', 'Forms', '/forms', False, []),
                ('Redirect', 'Redirect', '/redirect', False, []),
                ('Users', 'Users', '/users', False, []),
                ('Groups', 'Groups', '/groups', False, []),
                ('Files', 'Files', '/files', False, [])
            ]),
        ]),
        ('Activiteiten', 'Activities', '/activities', True, [
            ('Activiteiten Archief', 'Activities archive',
             '/activities/archive', False, []),
            ('Activiteiten Overzicht', 'Activities overview',
             '/activities/view', False, [])
        ]),
        ('Vacatures', 'Vacancies', '/vacancies/', False, []),
        ('Tentamenbank', 'Examinations', '/examination', False, []),
        ('Samenvattingen', 'Summaries', '/summary', False, [])
    ]

    _add_navigation(navigation_entries)

    print("* Adding administrator user")

    first_name = prompt("\tFirst name")
    last_name = prompt("\tLast name")

    email_regex = re.compile("^[^@]+@[^@]+\.[^@]+$")
    while True:
        email = prompt("\tEmail")
        if email_regex.match(email):
            break
        print("\tInvalid email address: " + email)

    while True:
        passwd_plain = prompt_pass("\tPassword")
        passwd_plain_rep = prompt_pass("\tRepeat password")
        if passwd_plain == passwd_plain_rep:
            break
        print("\tPasswords do not match")

    passwd = bcrypt.hashpw(passwd_plain.encode('utf-8'), bcrypt.gensalt())
    admin = User(
        first_name=first_name,
        last_name=last_name,
        email=email,
        password=passwd,
        education_id=Education.query.first().id)
    admin.has_paid = True
    _add_user(admin, "A user with email '{}' already exists".format(email))

    # Add admin user to administrators group
    admin_group = Group.query.filter_by(name='administrators').first()
    admin_group.add_user(admin)
    db.session.commit()

    roles = []
    for role in Roles:
        group_role = GroupRole()
        group_role.group_id = admin_group.id
        group_role.role = role.name
        roles.append(group_role)

    # Grant read/write privilege to administrators group on every module
    db.session.bulk_save_objects(roles)
    db.session.commit()

    print("* Adding default settings")

    settings = {'SECRET_KEY': 'localsecret',
                "CSRF_ENABLED": "True",
                "CSRF_SESSION_KEY": "localsession",
                "RECAPTCHA_PUBLIC_KEY": "",
                "RECAPTCHA_PRIVATE_KEY": "",
                "GOOGLE_SERVICE_EMAIL": "*****@*****.**",
                "GOOGLE_CALENDAR_ID": "",
                "ELECTIONS_NOMINATE_START": "2014-12-12",
                "ELECTIONS_VOTE_START": "2015-01-05",
                "ELECTIONS_VOTE_END": "2015-01-16",
                "GITLAB_TOKEN": "",
                "MOLLIE_URL": "https://api.mollie.nl/v1/payments/",
                "MOLLIE_KEY": "",
                "COPERNICA_ENABLED": "False",
                "COPERNICA_API_KEY": "",
                "COPERNICA_DATABASE_ID": "",
                "COPERNICA_ACTIEPUNTEN": "",
                "COPERNICA_ACTIVITEITEN": "",
                "COPERNICA_NEWSLETTER_TOKEN": "",
                "DOMJUDGE_ADMIN_USERNAME": "******",
                "DOMJUDGE_ADMIN_PASSWORD": "",
                "DOMJUDGE_URL": "",
                "DOMJUDGE_USER_PASSWORD": "",
                "SENTRY_DSN": "DUMMY",
                "ENVIRONMENT": "Development",
                "PRIVACY_POLICY_URL_EN": "/static/via_privacy_policy_nl.pdf",
                "PRIVACY_POLICY_URL_NL": "/static/via_privacy_policy_en.pdf"}
    for key, value in settings.items():
        if Setting.query.filter(Setting.key == key).count() > 1:
            print(f"-> {key} already exists")
        else:
            db.session.add(Setting(key=key, value=value))
            print(f"-> {key} added to database.")

    db.session.commit()

    print("Done!")
コード例 #51
0
ファイル: test.py プロジェクト: guoylyy/JustGo_Project
def refresh():
    db.drop_all()
    db.create_all()
    make_test_data()
コード例 #52
0
ファイル: manage.py プロジェクト: allanice001/microsnap
def create_db():
    "Create a new database"
    db.create_all(bind=None)
コード例 #53
0
ファイル: __init__.py プロジェクト: shulhi/flask-skeleton
 def setUp(self):
     db.create_all()
     self.init_seed()
コード例 #54
0
ファイル: fixture_app.py プロジェクト: kuc2477/devit
def db(app):
    database.create_all()
    yield database
    database.drop_all()
コード例 #55
0
ファイル: helper.py プロジェクト: gye-tgm/trackit
from app import create_app
from app.config import BaseConfiguration
from app.extensions import db
from app.models import User, TwitterPost

app = create_app(BaseConfiguration)
db.create_all()

User.create(username='******', password='******', role=1)
User.create(username='******', password='******', role=0)
TwitterPost.create()
コード例 #56
0
ファイル: manage.py プロジェクト: cymoo/very-simple
def create_db():
    db.create_all()
コード例 #57
0
def initdb():
    """Init/reset database."""
    db.drop_all()
    db.create_all()
コード例 #58
0
ファイル: manage.py プロジェクト: MedQA/medqa
def initdb():
    db.drop_all(bind=None)
    db.create_all(bind=None)
コード例 #59
0
ファイル: manage.py プロジェクト: shulhi/flask-skeleton
def initdb():
    db.drop_all()
    db.create_all()
コード例 #60
0
ファイル: helpers.py プロジェクト: jkeat/simple-nickels
 def setUp(self):
     db.create_all()