def _process_null_records(table, col_name, check_fkeys, delete=False):
 records = 0
 if (col_name in table.columns):
  if check_fkeys:
   fkey_found = False
   fkeys = (table.c[col_name].foreign_keys or [])
   for fkey in fkeys:
    if (fkey.column.table.name == 'instances'):
     fkey_found = True
   if (not fkey_found):
    return 0
  if delete:
   records = table.delete().where((table.c[col_name] == null())).execute().rowcount
  else:
   records = len(list(table.select().where((table.c[col_name] == null())).execute()))
 return records

def _process_null_records ( table , col_name , check_fkeys , delete = False ) : records = 0 if ( col_name in table . columns ) : if check_fkeys : fkey_found = False fkeys = ( table . c [ col_name ] . foreign_keys or [ ] ) for fkey in fkeys : if ( fkey . column . table . name == 'instances' ) : fkey_found = True if ( not fkey_found ) : return 0 if delete : records = table . delete ( ) . where ( ( table . c [ col_name ] == null ( ) ) ) . execute ( ) . rowcount else : records = len ( list ( table . select ( ) . where ( ( table . c [ col_name ] == null ( ) ) ) . execute ( ) ) ) return records
queries the database and optionally deletes the null records .