コード例 #1
0
def create_tables():
	if '--create' in sys.argv or '-c' in sys.argv:
		database.create_all()

	if '--insert' in sys.argv or '-i' in sys.argv:
		for query in insert_queries:
			database.session.execute(query) 
		database.session.commit()
コード例 #2
0
ファイル: app.py プロジェクト: axis93/Street_Soccer_PITCH
def create_tables():
    # if the database file already exists, don't recreate it
    if not os.path.isfile('database.db'):
        database.create_all()

    # if the data of the first insert (of 'instert_queries' in database.py) doesn't exist in the table, the test data hasn't been inserted yet, so insert it
    from models.topic import TopicModel
    if not TopicModel.query.first(
    ):  # prevent "UNIQUE constraint violation" of primary keys: this will only work as long as a topic is the first thing being inserted (you could fix this by checking every table is empty, but: a. unless you need something to be inserted before a topic there's no reason to rearrange it, and b. this is just test data so this won't be used in release)
        test.insert_test_data()
        database.session.commit()
コード例 #3
0
ファイル: app.py プロジェクト: gajaka/hangman
def create_tables():
    database.create_all()
コード例 #4
0
def create_all_tables_before_requests():
    db.create_all()