def init_database(): database.connect() database.create_tables([Post, User]) User.truncate_table() Post.truncate_table() repos = load_json('repos.json') for repo in repos: user, created = build_user(repo['owner']['login']) Post.create(title=repo['name'], slug=repo['full_name'], body=repo['description'], user=user) database.close()
def tearDown(self): database.drop_tables([PlaceBook, Place, User, State, City]) database.close()
def tearDown(self): database.drop_tables([User, State, City, Place, Review, ReviewUser, ReviewPlace]) database.close()
def tearDown(self): database.drop_tables([City, State, Place, User, PlaceBook]) database.close()
def tearDown(self): database.drop_tables([State]) database.close()
def after_request(response): database.close() return response
def tearDown(self): database.drop_tables([Amenity, PlaceAmenities, Place, State, User, City]) database.close()
from app.models.base import database from app.models.user import User from app.models.city import City from app.models.state import State from app.models.place import Place from app.models.place_book import PlaceBook from app.models.amenity import Amenity from app.models.place_amenity import PlaceAmenities from app.models.review import Review from app.models.review_user import ReviewUser from app.models.review_place import ReviewPlace database.connect() database.create_tables([User, State, City, Place, Amenity, PlaceBook, PlaceAmenities, Review, ReviewUser, ReviewPlace], safe = True) database.close()
def after_request(): database.close()
def tearDown(self): database.drop_tables( [User, State, City, Place, Review, ReviewUser, ReviewPlace]) database.close()
from app.models.base import database from app.models.user import User from app.models.city import City from app.models.state import State from app.models.place import Place from app.models.place_book import PlaceBook from app.models.amenity import Amenity from app.models.place_amenity import PlaceAmenities from app.models.review import Review from app.models.review_place import ReviewPlace from app.models.review_user import ReviewUser ''' Initializes each table in the database ''' database.connect() database.create_tables([User, State, City, Place, Amenity, PlaceBook, PlaceAmenities, Review, ReviewUser, ReviewPlace], safe=True) database.close()
def tearDown(self): database.drop_tables([User]) database.close()