def insert_many(self, table_name, records, attr_names=None):
self.validate_access_permission(["<STR_LIT:w>", "<STR_LIT:a>"])<EOL>self.verify_table_existence(table_name)<EOL>if attr_names:<EOL><INDENT>logger.debug(<EOL>"<STR_LIT>".format(<EOL>number=len(records) if records else <NUM_LIT:0>, table=table_name, attrs=attr_names<EOL>)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>logger.debug(<EOL>"<STR_LIT>".format(<EOL>number=len(records) if records else <NUM_LIT:0>, table=table_name<EOL>)<EOL>)<EOL><DEDENT>if typepy.is_empty_sequence(records):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>if attr_names is None:<EOL><INDENT>attr_names = self.fetch_attr_names(table_name)<EOL><DEDENT>records = RecordConvertor.to_records(attr_names, records)<EOL>query = Insert(table_name, AttrList(attr_names)).to_query()<EOL>if self.debug_query or self.global_debug_query:<EOL><INDENT>logging_count = <NUM_LIT:8><EOL>num_records = len(records)<EOL>logs = [query] + [<EOL>"<STR_LIT>".format(i, record)<EOL>for i, record in enumerate(records[:logging_count])<EOL>]<EOL>if num_records - logging_count > <NUM_LIT:0>:<EOL><INDENT>logs.append(<EOL>"<STR_LIT>".format(num_records - logging_count)<EOL>)<EOL><DEDENT>logger.debug("<STR_LIT:\n>".join(logs))<EOL><DEDENT>try:<EOL><INDENT>self.connection.executemany(query, records)<EOL><DEDENT>except (sqlite3.OperationalError, sqlite3.IntegrityError) as e:<EOL><INDENT>caller = logging.getLogger().findCaller()<EOL>file_path, line_no, func_name = caller[:<NUM_LIT:3>]<EOL>raise OperationalError(<EOL>"<STR_LIT>".format(file_path, line_no, func_name)<EOL>+ "<STR_LIT>".format(query)<EOL>+ "<STR_LIT>".format(e)<EOL>+ "<STR_LIT>".format(self.database_path)<EOL>+ "<STR_LIT>".format(records[:<NUM_LIT:2>])<EOL>)<EOL><DEDENT>return len(records)<EOL>
Send an INSERT query with multiple records to the database.

:param str table: Table name of executing the query.
:param records: Records to be inserted.
:type records: list of |dict|/|namedtuple|/|list|/|tuple|
:return: Number of inserted records.
:rtype: int
:raises IOError: |raises_write_permission|
:raises simplesqlite.NullDatabaseConnectionError:
    |raises_check_connection|
:raises simplesqlite.TableNotFoundError:
    |raises_verify_table_existence|
:raises simplesqlite.OperationalError: |raises_operational_error|

:Example:
    :ref:`example-insert-records`