コード例 #1
0
def db():
    from service import db
    with app.app_context():
        db.create_all()
        yield db
        db.drop_all()
        db.session.commit()
コード例 #2
0
ファイル: base_test.py プロジェクト: plutokid/pwitter
    def setUp(self):
        app.config.from_object('testing.TestConfig')
        self.app = app.test_client()

        db.create_all()

        fixtures.load_fixtures(
            loaders.load('testing/fixtures/user.json'))
        fixtures.load_fixtures(
            loaders.load('testing/fixtures/broadcaster2_follower.json'))
        fixtures.load_fixtures(
            loaders.load('testing/fixtures/tweet.json'))


        # manually setting date_created; I don't believe 
        # Flask-Fixtures supports setting dates
        renee_tweet = Tweet.query.filter_by(id=1).first()
        renee_tweet.date_created = datetime.date(2015, 1, 1)

        trenton_tweet = Tweet.query.filter_by(id=2).first()
        trenton_tweet.date_created = datetime.date(2015, 1, 2)

        db.session.add(renee_tweet)
        db.session.add(trenton_tweet)
        db.session.commit()
コード例 #3
0
def client():
    ## Setup for each test ##
    app.config['TESTING'] = True
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@testdb:5432/mytestdb'

    client = app.test_client()

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

    yield client

    ## Teardown for each test ##
    with app.app_context():
        db.session.close()
        db.drop_all()
コード例 #4
0
 def setUp(self):
     app.config["TESTING"] = True
     app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///data/test.db"
     self.app = app.test_client()
     db.create_all()
     self.data = {'code': 'g',
     'description': 'Giulia',
     'designer': 'alice',
     'gender': 'F',
     'image_urls': ['http://www.oxygenboutique.com/GetImage/d',
                    'http://www.oxygenboutique.com/GetImage/d'],
     'last_updated': '2013-07-12 17:25:24',
     'name': 'Giulia Emb',
     'price': 690.0,
     'raw_color': '',
     'sale_discount': 0,
     'source_url': 'http://www.oxygenboutique.com/giulia-em',
     'stock_status': {u'L': 1, u'M': 1, u'S': 3, u'XS': 3},
     'type': 'A'}
     self.data["__type__"] = "Product"
コード例 #5
0
ファイル: base_test.py プロジェクト: petypi/pwitter
    def setUp(self):
        app.config.from_object('testing.TestConfig')
        self.app = app.test_client()

        db.create_all()

        fixtures.load_fixtures(loaders.load('testing/fixtures/user.json'))
        fixtures.load_fixtures(
            loaders.load('testing/fixtures/broadcaster2_follower.json'))
        fixtures.load_fixtures(loaders.load('testing/fixtures/tweet.json'))

        # manually setting date_created; I don't believe
        # Flask-Fixtures supports setting dates
        renee_tweet = Tweet.query.filter_by(id=1).first()
        renee_tweet.date_created = datetime.date(2015, 1, 1)

        trenton_tweet = Tweet.query.filter_by(id=2).first()
        trenton_tweet.date_created = datetime.date(2015, 1, 2)

        db.session.add(renee_tweet)
        db.session.add(trenton_tweet)
        db.session.commit()
コード例 #6
0
def create_app(testing=False):
    """
    Create a Flask app instance,
    sets SQLALCHEMY configurations
    """
    migrate = Migrate()

    app = Flask(__name__)
    app.register_blueprint(views_bp, url_prefix="")

    app.config["LOG_LEVEL"] = "INFO"

    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3'

    db.init_app(app)

    migrate.init_app(app, db)

    db.create_all(app=app)
    setup_logging(app)

    return app
コード例 #7
0
ファイル: manage.py プロジェクト: ACM-CSUSB/Website
def create():
    "Creates database tables from sqlalchemy models"
    db.create_all()
コード例 #8
0
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.

import argparse
from service import db
from models.pipeline import Pipeline
from models.application import Application
from models.mapping import Mapping
from models.operator import Operator
try:
    db.create_all()
except Exception as e:
    print(e)
from service.api import app


def app_runner(args):
    if args.debug:
        debug = True
    app.run(host="0.0.0.0", debug=debug, port=5000)


def run_with_args():
    parser = argparse.ArgumentParser(description='Start args')
    parser.add_argument('--debug', action="store_true")
    args = parser.parse_args()
コード例 #9
0
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
コード例 #10
0
ファイル: create_db.py プロジェクト: plutokid/pwitter
#!flask/bin/python
from migrate.versioning import api
import os.path

from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from service import db, models

db.create_all()
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))
コード例 #11
0
 def setUp(self):
     db.create_all()
     db.session.commit()
コード例 #12
0
ファイル: manage.py プロジェクト: RC2K7/3DPrinting
def create():
    db.create_all()
コード例 #13
0
ファイル: base.py プロジェクト: bgoesswe/dataid_openeo
    def setUp(self):
        ''' Setup the database. '''

        db.create_all()
        db.session.commit()
コード例 #14
0
def init_db():
    db.create_all()
    db.session.commit()
コード例 #15
0
 def setUp(self):
     db.create_all()