code: def insert_record_by_dict(self,
                                table: str,
                                valuedict: Dict[str, Any]) -> Optional[int]:
          
          if not valuedict:
              return None
          n = len(valuedict)
          fields = []
          args = []
          for f, v in valuedict.items():
              fields.append(self.delimit(f))
              args.append(v)
          query = """
              INSERT INTO {table}
                  ({fields})
                  VALUES ({placeholders})
          """.format(
              table=table,
              fields=",".join(fields),
              placeholders=",".join(["?"]*n)
          )
          query = self.localize_sql(query)
          log.debug("About to insert_record_by_dict with SQL template: " + query)
          try:
              cursor = self.db.cursor()
              debug_sql(query, args)
              cursor.execute(query, args)
              new_pk = get_pk_of_last_insert(cursor)
              log.debug("Record inserted.")
              return new_pk
          except:  # nopep8
              log.exception("insert_record_by_dict: Failed to insert record.")
              raise
docs: Inserts a record into database, table "table", using a dictionary
          containing field/value mappings. Returns the new PK (or None).