code: def insert_record(self,
                        table: str,
                        fields: Sequence[str],
                        values: Sequence[Any],
                        update_on_duplicate_key: bool = False) -> int:
          
          self.ensure_db_open()
          if len(fields) != len(values):
              raise AssertionError("Field/value mismatch")
          if update_on_duplicate_key:
              sql = get_sql_insert_or_update(table, fields, self.get_delims())
          else:
              sql = get_sql_insert(table, fields, self.get_delims())
          sql = self.localize_sql(sql)
          log.debug("About to insert_record with SQL template: " + sql)
          try:
              cursor = self.db.cursor()
              debug_sql(sql, values)
              cursor.execute(sql, values)
              # ... binds the placeholders (?, %s) to values in the process
              new_pk = get_pk_of_last_insert(cursor)
              log.debug("Record inserted.")
              return new_pk
          except:  # nopep8
              log.exception("insert_record: Failed to insert record.")
              raise
docs: Inserts a record into database, table "table", using the list of
          fieldnames and the list of values. Returns the new PK (or None).