def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
Role.insert_roles()
python类create_all()的实例源码
def create_tables(add_data=False, create_directories=False):
if database_issue():
print('Before running this command database must be initialized by superuser with these commands:\n')
cmds = os.path.join(SQL_DIR, 'init_db.sql')
with open(cmds, 'rt') as f:
print(f.read())
db.create_all()
connection = db.engine.raw_connection() # @UndefinedVariable
try:
c = connection.cursor()
#insert current db version
c.execute('insert into version (version, version_id) values (%s, %s)', (db_version,1))
for fname in ('create_ts.sql', 'create_functions.sql'):
script = open(os.path.join(SQL_DIR, fname), 'rt', encoding='utf-8-sig').read()
# print(script)
res = c.execute(script)
connection.commit()
if add_data:
script = open(os.path.join(SQL_DIR, 'dump/basic.sql'), 'rt', encoding='utf-8-sig').read()
res = c.execute(script)
connection.commit()
print('Default admin user with password admin was created - change it manage.py change_password admin')
finally:
connection.close()
if create_directories:
for d in [settings.BOOKS_BASE_DIR, settings.BOOKS_CONVERTED_DIR, settings.UPLOAD_DIR, settings.THUMBS_DIR]:
os.makedirs(d, exist_ok=True)
print('Created directories')
def initdb():
db.create_all()
db.session.commit()
print 'Database initialized'
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
self.client = self.app.test_client(use_cookies=True)
# ??????
def setUp(self):
self.app = create_app()
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
# ??????
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
# ??????
def createdb():
db.create_all()
test_base.py 文件源码
项目:sarai-interactive-maps-backend
作者: ecsnavarretemit
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def setUp(self):
print "In method: %s" % self._testMethodName
db.create_all()
def setUpClass(cls):
with cls._app.app_context():
db.create_all()
db.session.commit()
def setUp(self):
self.app = create_app('comment')
self.app_context = self.app.app_context()
self.app_context.push()
db.init_app(self.app)
db.create_all()
table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
table_structs = copy.deepcopy(table_structs)
table_structs.pop('__tablename__')
self.proxy = CommentProxy([key for key, value in table_structs.items()])
def setUp(self):
self.app = create_app('comment')
self.app_context = self.app.app_context()
self.app_context.push()
db.init_app(self.app)
db.create_all()
table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
table_structs = copy.deepcopy(table_structs)
table_structs.pop('__tablename__')
self.proxy = CommentProxy([key for key, value in table_structs.items()])
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
Role.insert_roles()
self.client = self.app.test_client()
def create_db():
"""Creates the db tables."""
db.create_all()
def recreate_db():
"""
Recreates a local database. You probably should not use this on
production.
"""
db.drop_all()
db.create_all()
db.session.commit()
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()