• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python db.create_all函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中model.db.create_all函数的典型用法代码示例。如果您正苦于以下问题:Python create_all函数的具体用法?Python create_all怎么用?Python create_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_all函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):

        print "(setUp ran)"
        self.client = server.app.test_client()
        server.app.config['TESTING'] = True
        connect_to_test_db(server.app)
        db.create_all()
开发者ID:bekkam,项目名称:hackbright-project,代码行数:7,代码来源:tests.py


示例2: setUp

    def setUp(self):
        # Get the Flask test client
        self.client = app.test_client()

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True

        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")

        # Create tables from model
        db.create_all()

        # Import different types of data from seed file
        seed.load_users()
        seed.load_groups()
        seed.load_usergroups()
        seed.load_patterns()
        seed.load_invites()
        
        # Reset auto incrementing primary keys to start after seed data
        seed.set_val_user_id()
        seed.set_val_group_id()
        seed.set_val_usergroup_id()
        seed.set_val_pattern_id()
        seed.set_val_invite_id()
开发者ID:ltaziri,项目名称:Hackbright-FinalProject,代码行数:26,代码来源:flaskr_tests.py


示例3: setUp

    def setUp(self):
        """Stuff to do before every test."""

        self.client = app.test_client()
        app.config['TESTING'] = True

        # Connect to test database (uncomment when testing database)
        connect_to_db(app, "postgresql:///testdb")

        # Create tables and add sample data (uncomment when testing database)
        db.create_all()
        example_data()

        with self.client as c:
        with c.session_transaction() as sess:
            sess['RSVP'] = True

    def tearDown(self):
        """Do at end of every test."""

        # (uncomment when testing database)
        db.session.close()
        db.drop_all()

    def test_games(self):
        result = self.client.get("/games")
        self.assertIn("Clue", result.data)
开发者ID:cristinamclarkin,项目名称:Flask-testing,代码行数:27,代码来源:tests.py


示例4: setUp

    def setUp(self):

        print "(setUp ran)"
        self.client = server.app.test_client()          # Sets up fake test browser
        server.app.config['TESTING'] = True             # Makes a 500 error in a route raise an error in a test
        connect_to_db(app, "postgresql:///testdb")      # Connect to temporary DB
        db.create_all()
开发者ID:erinallard,项目名称:Hackbright_Project,代码行数:7,代码来源:tests.py


示例5: init

def init(configfile):
    app.config.from_pyfile('openmoves.cfg.default', silent=False)
    if configfile:
        if not os.path.exists(configfile):
            with open(configfile, 'w') as f:
                initialize_config(f)
            print("created %s" % configfile)

        app.config.from_pyfile(configfile, silent=False)
        assert app.config['SECRET_KEY']

        SESSION_VERSION = 1
        app.config['SECRET_KEY'] = "%s-%d" % (app.config['SECRET_KEY'], SESSION_VERSION)

    assert 'SQLALCHEMY_TRACK_MODIFICATIONS' not in app.config
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    db.init_app(app)

    with app.app_context():
        if db.engine.name == 'sqlite':
            db.create_all()

    Bootstrap(app)
    app_bcrypt.init_app(app)

    login_manager.init_app(app)
    login_manager.login_view = "login"

    return app
开发者ID:bwaldvogel,项目名称:openmoves,代码行数:30,代码来源:openmoves.py


示例6: setUp

    def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Mock session

        # Connect to temporary database
        connect_to_db(app, "sqlite:///")

        # Create tables and add sample data
        db.create_all()
        sample_data()


        def _mock_grab_image_dimensions(filename):
            return (920, 764)

        self._old_grab_image_dimensions = server.grab_image_dimensions
        server.grab_image_dimensions = _mock_grab_image_dimensions

        def _mock_generate_thumb(filename, crop_thumb):
            return None

        self._old_generate_thumb = server.generate_thumb
        server.generate_thumb = _mock_generate_thumb
开发者ID:zewlie,项目名称:wildally-project,代码行数:27,代码来源:tests.py


示例7: setUp

    def setUp(self):
        """Do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True

        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")
        db.create_all()

        # Make mocks
        def _mock_get_yelp_search_results(term, location, category_filter, limit):
            """Mocks search results of Yelp API call for one restaurant."""

            search_results = {"businesses": [{"rating": 4.5, "rating_img_url": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png", "review_count": 547, "name": "Saru Sushi Bar", "rating_img_url_small": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/a5221e66bc70/ico/stars/v1/stars_small_4_half.png", "url": "http://www.yelp.com/biz/saru-sushi-bar-san-francisco?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=6XuCRI2pZ5pIvcWc9SI3Yg", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/5-ugy01zjSvudVsfdhmCsA/ms.jpg", "display_phone": "+1-415-400-4510", "id": "saru-sushi-bar-san-francisco", "location": {"city": "San Francisco", "postal_code": "94114", "country_code": "US", "address": ["3856 24th St"], "coordinate": {"latitude": 37.751706, "longitude": -122.4288283}, "state_code": "CA"}}]}
            return search_results

        def _mock_is_open_now_true(keyword, location):
            """Mocks Google Places API call to return True for current open status."""

            return True

        self._old_is_open_now = process_results.is_open_now
        process_results.is_open_now = _mock_is_open_now_true

        self.old_get_yelp_search_results = server.yelp.search_query
        server.yelp.search_query = _mock_get_yelp_search_results
开发者ID:anniehe,项目名称:wait-time,代码行数:30,代码来源:tests.py


示例8: message

def message():
	db.create_all()
	if request.values.get('Body', None).strip().lower() == 'register':
		user = Users.query.filter_by(number=request.values.get('From')).first()
		if user:
			user.active = 1
			db.session.commit()
		else:
			user = Users(request.values.get('From'))
			db.session.add(user)
			db.session.commit()

		resp = twilio.twiml.Response()
		resp.message("Confirmed! Stay tuned for dog and cat pics! Text \"pause\" to stop hearing from us :( .")
		return str(resp)
	elif request.values.get('Body', None).strip().lower() == 'pause':
		user = Users.query.filter_by(number=request.values.get('From')).first()
		if not user:
			resp = twilio.twiml.Response()
			resp.message("Hmm - you're not in our system! Want to sign up? Reply with \"register\"")
			return str(resp)
		else:
			user.active = 0
			db.session.commit()
			resp = twilio.twiml.Response()
			resp.message("You won't get any more messages - for now. Reply with \"register\" to start receiving again.")
			return str(resp)
	else:
		resp = twilio.twiml.Response()
		resp.message("Sorry - I don't understand that command!")
		return str(resp)
开发者ID:jayrav13,项目名称:cat-tax,代码行数:31,代码来源:__init__.py


示例9: setUp

  def setUp(self):
    # init tables
    db.create_all()
    # do imports
    from model import User
    from model import ItemCategory, ItemManufacturer, Item
    from model import LocationBuilding, Location
    from model import AssetInfo, Asset
    from model import Inventory
    # create objects
    u1 = User('bob')
    cat = ItemCategory('Computer')
    man = ItemManufacturer('Dell')
    item = Item(cat,man,'Optiplex 360')
    building = LocationBuilding('CEER')
    location = Location(building,'008')
    tag = AssetInfo('ee02547','13349')
    asset = Asset(tag,0,item,owner=u1,current=location,ip='153.104.47.23')
    import datetime
    inv = Inventory(u1,asset,datetime.datetime.now(),location)

    # add to database
    db.session.add(u1)
    db.session.add(cat)
    db.session.add(man)
    db.session.add(building)
    db.session.add(tag)
    db.session.add(item)
    db.session.add(location)
    db.session.add(asset)
    db.session.add(inv)
    db.session.commit()
开发者ID:briansan,项目名称:inv,代码行数:32,代码来源:tests.py


示例10: setUp

    def setUp(self):
        """Setup to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # secret key to allow sessions to be used
        app.config['SECRET_KEY'] = 'sekrit!'

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True

        # Connect to test database
        connect_to_db(app, db_uri="postgresql:///testdb")

        # Create tables and add sample data
        db.create_all()
        # create db records for yarns, users, baskets, basket_yarns,
        #                       projects, and patterns
        create_example_data()
        # create db records for preferences and user_preferences
        load_preferences("test_data/preference_data.txt")
        load_user_preferences("test_data/user_preference_data.txt")

        with self.client as c:
                with c.session_transaction() as session:
                    session['username'] = 'u1'
开发者ID:karayount,项目名称:commuKNITty,代码行数:27,代码来源:test_server.py


示例11: create_app

def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = os.environ.get("FLASK_SECRET_KEY", "abcdef")
    db.init_app(app)
    with app.test_request_context():
        db.create_all()
    return app
开发者ID:tdiede,项目名称:hackscrapers_SF,代码行数:7,代码来源:server.py


示例12: __init__

 def __init__(self):
     logger.info("Message Manager init...")
     try:
         Message.query.all()
     except:
         db.create_all()
     logger.info("Message Manager init done...")
开发者ID:chenrui9551,项目名称:docklet,代码行数:7,代码来源:messageManager.py


示例13: setUp

    def setUp(self):
        print "\n\n\n\n (2) DOING A SEARCH TEST \n\n\n\n"
        self.client = app.test_client()
        app.config['TESTING'] = True
        postgrespassword = os.environ['POSTGRES_PASSWORD']
        db_uri = 'postgresql://' + postgrespassword + '/test'
        connect_to_db(app, db_uri)

        db.create_all()

        load_regions()
        load_users()
        load_bestuses()
        load_categories()
        load_brands()
        load_products()
        load_tents()
        load_filltypes()
        load_gendertypes()
        load_sleepingbags()
        load_padtypes()
        load_sleepingpads()
        load_ratings()
        load_histories()
        load_test_postalcodes()
开发者ID:fwong03,项目名称:watermelon,代码行数:25,代码来源:camper_tests.py


示例14: setUp

    def setUp(self):
        self.client = app.test_client()
        app.config["TESTING"] = True
        app.config["SECRET_KEY"] = "key"

        connect_to_db(app, db_uri="postgresql:///testdb")

        db.create_all()
开发者ID:ibhan88,项目名称:Project---Vegan-Recipes,代码行数:8,代码来源:tests.py


示例15: setUp

    def setUp(self):
        """Set up app, session key, and fake client."""

        app.config['TESTING'] = True
        self.client = app.test_client()

        connect_to_db(app, 'postgresql:///testdb')
        db.create_all()
开发者ID:ainjii,项目名称:muse,代码行数:8,代码来源:test_server.py


示例16: setUp

 def setUp(self):
     self.app = app.test_client()
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
     db.app = app
     db.init_app(app)
     db.create_all()
开发者ID:eileenconner,项目名称:law-admissions-tool,代码行数:8,代码来源:tests2.py


示例17: setUp

    def setUp(self):

        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")

        # Create tables and add sample data
        db.create_all()
        example_data()
开发者ID:sarahcstringer,项目名称:hackbright-project,代码行数:8,代码来源:unit_test.py


示例18: setUp

 def setUp(self):
     """before every test"""
     
     self.client = app.test_client()
     app.config['TESTING'] = True
     connect_to_db(app, 'postgresql:///testsubreddits')
     db.create_all()
     make_test_data()
开发者ID:loribard,项目名称:personalized_news.mainrepo,代码行数:8,代码来源:testing.py


示例19: setUp

    def setUp(self):
        self.client = app.test_client()
        app.config['TESTING'] = True

        connect_to_db(app, "postgresql:///testdb")

        db.create_all()

        fake_data()
开发者ID:ssong319,项目名称:indproject,代码行数:9,代码来源:tests.py


示例20: setUp

    def setUp(self):
        """Stuff to do before every test."""

        self.client = app.test_client()

        connect_to_db(app, "sqlite:///")

        db.create_all()
        example_data()
开发者ID:allymcknight,项目名称:CompanyClimate,代码行数:9,代码来源:tests.py



注:本文中的model.db.create_all函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.drop_all函数代码示例发布时间:2022-05-27
下一篇:
Python database.Database类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap