def truncate(engine): """ Remove data from existing tables """ conn = engine.connect() for table in Node.get_subclass_table_names(): if table != Node.__tablename__: conn.execute('delete from {}'.format(table)) for table in Edge.get_subclass_table_names(): if table != Edge.__tablename__: conn.execute('delete from {}'.format(table)) # Extend this list as needed ng_models_metadata = [ models.versioned_nodes.Base.metadata, models.submission.Base.metadata, models.redaction.Base.metadata, models.qcreport.Base.metadata, models.misc.Base.metadata, ] for meta in ng_models_metadata: for table in meta.tables: conn.execute("DELETE FROM {}".format(table)) conn.close()
def _clear_tables(self): conn = g.engine.connect() conn.execute('commit') for table in Node.get_subclass_table_names(): if table != Node.__tablename__: conn.execute('delete from {}'.format(table)) conn.execute('delete from {}'.format('_voided_nodes')) conn.close()