def truncate_all_tables(session: Session): table_names = session.execute(""" select table_name from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE' and table_name != 'alembic_version' """) for (table_name,) in table_names: # "truncate" can deadlock so we use delete which is guaranteed not to. session.execute(f"delete from {table_name}") session.commit()
def _create_user(session: Session): user = UserModel(email=email, display_name=display_name, password=password) session.add(user) session.commit()