@set_database
def bulk_insert(items, **kwargs):
 if items:
  db = kwargs.get('db')
  items = map(parse_model_data, items)
  if db:
   with db.atomic():
    for idx in range(0, len(items), 500):
     Item.insert_many(items[idx:(idx + 500)]).execute()

@ set_database def bulk_insert ( items , ** kwargs ) : if items : db = kwargs . get ( 'db' ) items = map ( parse_model_data , items ) if db : with db . atomic ( ) : for idx in range ( 0 , len ( items ) , 500 ) : Item . insert_many ( items [ idx : ( idx + 500 ) ] ) . execute ( )
insert many rows into the database at once .