本文整理汇总了Python中model.db.drop_all函数的典型用法代码示例。如果您正苦于以下问题:Python drop_all函数的具体用法?Python drop_all怎么用?Python drop_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'
示例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")
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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'
示例10: tearDown
def tearDown(self):
"""Do at the end of every test."""
db.session.close()
db.drop_all()
示例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()
示例12: tearDown
def tearDown(self):
db.session.remove()
db.drop_all()
示例13: tearDown
def tearDown(self):
"""Stub function for later."""
print "(tearDown ran)"
db.session.close()
db.drop_all()
示例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!")
示例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()