code: def namedb_insert_prepare( cur, record, table_name ):
      
  
      namedb_assert_fields_match( cur, record, table_name )
       
      columns = record.keys()
      columns.sort()
  
      values = []
      for c in columns:
          if record[c] == False:
              values.append(0)
          elif record[c] == True:
              values.append(1)
          else:
              values.append(record[c])
      
      values = tuple(values)
  
      field_placeholders = ",".join( ["?"] * len(columns) )
  
      query = "INSERT INTO %s (%s) VALUES (%s);" % (table_name, ",".join(columns), field_placeholders)
      log.debug(namedb_format_query(query, values))
  
      return (query, values)
docs: Prepare to insert a record, but make sure
      that all of the column names have values first!
  
      Return an INSERT INTO statement on success.
      Raise an exception if not.