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

Python db.drop_all函数代码示例

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

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



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

示例1: setUp

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

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

        # 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")

        # start with empty db
        db.drop_all()
        # 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")
        load_group_events("test_data/group-events.csv")

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


示例2: setUp

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

        # Get the Flask test client
        self.client = app.test_client()
        app.jinja_env.undefined = StrictUndefined
        app.jinja_env.filters['prettify_preference'] = prettify_preference

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

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

        # start with empty db
        db.drop_all()
        # 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")
        load_group_events("test_data/group-events.csv")
开发者ID:karayount,项目名称:commuKNITty,代码行数:25,代码来源:test_server.py


示例3: tearDown

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

        server.yelp.search_query = self.old_get_yelp_search_results
        process_results.is_open_now = self._old_is_open_now

        db.session.close()
        db.drop_all()
开发者ID:anniehe,项目名称:wait-time,代码行数:8,代码来源:tests.py


示例4: setUp

    def setUp(self):
        """Do at the start of every test"""

        self.client = app.test_client()
        app.config['TESTING'] = True
        connect_to_db(app, "postgresql:///test_questions")

        db.drop_all()
        db.create_all()

        example_data()
开发者ID:beatricep,项目名称:6-Mturk-Final-Project,代码行数:11,代码来源:tests.py


示例5: sample_data

def sample_data():
	"""create sample data"""

	# In case this is run more than once, dump existing data
	db.drop_all()
	db.create_all()

	# Add sample Uers
	user1 = User(first_name='pablo', last_name='penguin', contact_num='5109266821', nvmd_code='123')

	db.session.add_all([user1])
	db.session.commit()

	pablo_id = User.query.filter_by(first_name='pablo').first().user_id

	# Add sample friends
	friend1 = Friendfirst_name='pablo', last_name='penguin', contact_num='5109266821')

	db.session.add_all([friend1])
	db.session.commit()
开发者ID:glasses4days,项目名称:safebot,代码行数:20,代码来源:seed.py


示例6: setUp

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

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

        # 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")

        # start with empty db
        db.drop_all()
        # Create tables and add sample data
        db.create_all()
开发者ID:karayount,项目名称:commuKNITty,代码行数:20,代码来源:test_seed.py


示例7: setUp

    def setUp(self):
        mail.outbox[:] = []
        db.session.rollback()
        if getattr(conf, "created_db", False):
            truncate_tables()
        else:
            try:
                db.drop_all()
            except Exception as e:
                print(e)
            db.create_all()
            conf.created_db = True

        clear_mem_db()
        self.bootstrap()

        self.service_nano_id = Flavor.get_service_id('Nano')
        self.service_micro_id = Flavor.get_service_id('Micro')
        self.service_small_id = Flavor.get_service_id('Small')
        self.service_medium_id = Flavor.get_service_id('Medium')

        openstack._OpenStackAuth__auth["auth_url"] = "test.should.not.connect.to.open.stack.com"
        openstack.change_tenant_quotas = mock.MagicMock()
        openstack.update_user = mock.MagicMock()
        openstack.stop_instances = mock.MagicMock()
        openstack.start_instances = mock.MagicMock()
        openstack.client_neutron.create_network = mock.MagicMock(side_effect=Network)
        openstack.client_neutron.create_subnet = mock.MagicMock(side_effect=Subnet)
        openstack.client_neutron.create_router = mock.MagicMock(side_effect=Router)
        openstack.client_neutron.add_interface_router = mock.MagicMock()
        openstack.client_neutron.list_floatingips = mock.MagicMock(return_value={"floatingips": []})
        openstack.client_neutron.list_routers = mock.MagicMock(return_value={"routers": []})
        openstack.client_neutron.list_networks = mock.MagicMock(return_value={"networks": []})
        openstack.client_neutron.list_subnets = mock.MagicMock(return_value={"subnets": []})
        openstack.client_neutron.list_ports = mock.MagicMock(return_value={"ports": []})
        openstack.client_neutron.list_security_groups = mock.MagicMock(return_value={"security_groups": []})
        openstack.client_neutron.list_vpnservices = mock.MagicMock(return_value={"vpnservices": []})

        super().setUp()
开发者ID:deti,项目名称:boss,代码行数:39,代码来源:base.py


示例8: setUp

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

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

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

        # Connect to test database
        # @todo set from environment config
        connect_to_db(controller.app, 'postgresql:///dogwalker')

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

        # # Populate the test data
        populate_business()
        populate_users()
        populate_animals()
        populate_people()
        populate_services()
        populate_reservations()
开发者ID:manishapme,项目名称:hb_dogwalker,代码行数:24,代码来源:test.py


示例9: tearDown

 def tearDown(self): #: called after the test is run (close shit)
     db.session.remove() # REALLY IMPORTANT to do this before the one below, otherwise can't run more than one test
     db.drop_all() #: get rid of tables
     print '===> teardown: end'
开发者ID:tomov,项目名称:echo-webapp,代码行数:4,代码来源:base.py


示例10: tearDown

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

        db.session.close()
        db.drop_all()
开发者ID:Aisling-Dempsey,项目名称:testing-2,代码行数:5,代码来源:tests.py


示例11: refresh_db

def refresh_db():
    with app.app_context():
        db.drop_all()
        db.create_all()
        db.session.add(User(username='bill.murray', email='[email protected]'))
        db.session.commit()
开发者ID:macrotim,项目名称:tutorials-applied,代码行数:6,代码来源:app.py


示例12: tearDown

 def tearDown(self):
   db.session.remove()
   db.drop_all()
开发者ID:briansan,项目名称:inv,代码行数:3,代码来源:tests.py


示例13: tearDown

 def tearDown(self):
     """Stub function for later."""
     print "(tearDown ran)"
     db.session.close()
     db.drop_all()
开发者ID:bekkam,项目名称:hackbright-project,代码行数:5,代码来源:tests.py


示例14: print

import sys
sys.path.append("../src/")
from model import db,User

print("Query all users:")
users = User.query.all()
print(users)
newusers = []
print("Copy data to new users and set their beans to 10000...")
for user in users:
    newuser = User(user.username,user.password,user.avatar,user.nickname,user.description,user.status,
                    user.e_mail,user.student_number,user.department,user.truename,user.tel,user.register_date,
                    user.user_group,user.auth_method)
    newuser.beans = 10000
    newusers.append(newuser)
print("Drop all table...")
db.drop_all(bind='__all__')
print("Create all tables with beans...")
setattr(User,'beans',db.Column(db.Integer))
db.create_all(bind='__all__')
for newuser in newusers:
    db.session.add(newuser)
    db.session.commit()
print("Update users table successfully!")
开发者ID:FirmlyReality,项目名称:docklet,代码行数:24,代码来源:alterUserTable.py


示例15: load_user_chore

def load_user_chore():
    """Load user chores from user_chore into database."""
    seed_file = open("seed_data/user_chore")
    for line in seed_file:
        line = line.rstrip()
        seed_line = line.split("\t")
        
        new_user_chore = UserChore(
            user_id=int(seed_line[0]),
            chore_id=int(seed_line[1]),
            due_date=datetime.strptime(seed_line[2], "%w, %m/%d/%y"))

        db.session.add(new_user_chore)
    db.session.commit() 




if __name__ == "__main__":
    connect_to_db(app)
    db.drop_all()
    db.create_all()

    # import pdb; pdb.set_trace()

    load_houses()
    load_users()
    load_chore()
    load_house_chore()
    load_user_chore()
开发者ID:janet,项目名称:choreme,代码行数:30,代码来源:seed.py


示例16: tearDown

 def tearDown(self):
     """
     Delete our testing database
     """
     db.session.remove()
     db.drop_all()
开发者ID:leskat47,项目名称:brew-app-project,代码行数:6,代码来源:test.py


示例17: tearDown

 def tearDown(self):
     """Remove testing db"""
     db.session.remove()
     db.drop_all()
     print "teardown ran"
开发者ID:eileenconner,项目名称:law-admissions-tool,代码行数:5,代码来源:tests.py


示例18: sample_data

def sample_data():
	"""create sample data"""

	# In case this is run more than once, dump existing data
	db.drop_all()
	db.create_all()

	# Add sample Uers
	user1 = User(user_name='Kelly', password='1234', email='[email protected]')
	user2 = User(user_name='Kate', password='1234', email='[email protected]')
	user3 = User(user_name='Jack', password='1234', email='[email protected]')

	db.session.add_all([user1, 
	                    user2,
	                    user3])
	db.session.commit()

	kelly_id = User.query.filter_by(user_name='Kelly').first().user_id
	kate_id = User.query.filter_by(user_name='Kate').first().user_id
	jack_id = User.query.filter_by(user_name='Jack').first().user_id

	    # Add sample locations
	location1 = Location(location_name='New York')
	location2 = Location(location_name='San Francisco')
	location3 = Location(location_name='Rome')
	location4 = Location(location_name='Tokyo')

	db.session.add_all([location1,
	                    location2,
	                    location3,
	                    location4])

	db.session.commit()  

	NY = Location.query.filter_by(location_name='New York').first().location_id
	SF = Location.query.filter_by(location_name='San Francisco').first().location_id
	RM = Location.query.filter_by(location_name='Rome').first().location_id
	TK = Location.query.filter_by(location_name='Tokyo').first().location_id

	# Add sample lists
	list1 = List(list_name='My New York', user_id=kelly_id, location_id=NY)
	list2 = List(list_name='I love SF', user_id=kate_id, location_id=SF)
	list3 = List(list_name='Rome yay', user_id=jack_id, location_id=RM)
	list4 = List(list_name='Kate NYC', user_id=kate_id, location_id=NY)
	list5 = List(list_name='Kelly SF', user_id=kelly_id, location_id=SF)
	list6 = List(list_name='Rome in Summer', user_id=kelly_id, location_id=RM)
	list7 = List(list_name='Tokyo with Noel', user_id=kelly_id, location_id=TK)



	db.session.add_all([list1,
	                    list2,
	                    list3,
	                    list4,
	                    list5,
	                    list6,
	                    list7])

	db.session.commit()

	lst1 = List.query.filter_by(list_name='My New York').first().list_id
	lst2 = List.query.filter_by(list_name='I love SF').first().list_id
	lst3 = List.query.filter_by(list_name='Rome yay').first().list_id
	lst4 = List.query.filter_by(list_name='Kate NYC').first().list_id
	lst5 = List.query.filter_by(list_name='Kelly SF').first().list_id
	lst6 = List.query.filter_by(list_name='Rome in Summer').first().list_id
	lst7 = List.query.filter_by(list_name='Tokyo with Noel').first().list_id


	# Add sample categories
	category1 = Category(category_name='restaurant')
	category2 = Category(category_name='museum')
	category3 = Category(category_name='bar')

	db.session.add_all([category1,
	         	        category2,
	                    category3])

	db.session.commit()

	r1 = Category.query.filter_by(category_name='restaurant').first().category_id
	r2 = Category.query.filter_by(category_name='museum').first().category_id
	r3 = Category.query.filter_by(category_name='bar').first().category_id

	# Add sample items for lists
	item1 = Item(item_name='PickMeUp', item_comments='our favorite cafe from college', item_address='address, ny', list_id=lst1, category_id=r1)
	item2 = Item(item_name='Foreign Cinema', item_comments='fried chicken', item_address='address, sf', list_id=lst2, category_id=r1)
	item3 = Item(item_name='San Crispino', item_comments='eat all the gelato', item_address='address, rome', list_id=lst3, category_id=r1)
	item4 = Item(item_name='The Vatican', item_comments='Amazing assortment of tourists, all the people watching', item_address='Vatican City', list_id=lst6, category_id=r2)
	item5 = Item(item_name="Rocco's", item_comments='cannoli and cheesecake', item_address='400 Bleeker St, NY, NY', list_id=lst4, category_id=r1)
	item6 = Item(item_name='Brothers Korean BBQ', item_comments='Bi Bim Bop!', item_address='Geary at 6th St, SF, CA', list_id=lst5, category_id=r3)
	item7 = Item(item_name='Robot Cafe', item_comments='Robot waiters', item_address='Tokyo', list_id=lst7, category_id=r3)



	#Add all the data to the session
	db.session.add_all([ item1,
	                    item2,
	                    item3, 
	                    item4,
#.........这里部分代码省略.........
开发者ID:kelly4strength,项目名称:go-there-list,代码行数:101,代码来源:sample_data.py


示例19: dropall

def dropall():
    "Drops all database tables"

    if prompt_bool("Are you sure ? You will lose all your data !"):
        db.drop_all()
开发者ID:erhuabushuo,项目名称:flaskblog-blueprints,代码行数:5,代码来源:manager.py


示例20: setUp

 def setUp(self):
     db.drop_all()
     db.create_all()
开发者ID:openemotion,项目名称:webapp,代码行数:3,代码来源:model_tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db_session.DB_Session_Factory类代码示例发布时间:2022-05-27
下一篇:
Python db.create_all函数代码示例发布时间: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