def cleanup_db():
 conn = get_db_conn()
 curs = conn.cursor()
 try:
  curs.execute('DELETE FROM base_contactrole WHERE resource_id is NULL;')
  curs.execute('DELETE FROM base_link WHERE resource_id is NULL;')
 except Exception as err:
  try:
   conn.rollback()
  except:
   pass
  traceback.print_exc()
 conn.commit()

def cleanup_db ( ) : conn = get_db_conn ( ) curs = conn . cursor ( ) try : curs . execute ( 'DELETE FROM base_contactrole WHERE resource_id is NULL;' ) curs . execute ( 'DELETE FROM base_link WHERE resource_id is NULL;' ) except Exception as err : try : conn . rollback ( ) except : pass traceback . print_exc ( ) conn . commit ( )
remove spurious records from geonode db .