MCPcopy
hub / github.com/piccolo-orm/piccolo / insert

Method insert

piccolo/table.py:1061–1077  ·  view source on GitHub ↗

Insert rows into the database. .. code-block:: python await Band.insert( Band(name="Pythonistas", popularity=500, manager=1) )

(
        cls: type[TableInstance], *rows: TableInstance
    )

Source from the content-addressed store, hash-verified

1059
1060 @classmethod
1061 def insert(
1062 cls: type[TableInstance], *rows: TableInstance
1063 ) -> Insert[TableInstance]:
1064 """
1065 Insert rows into the database.
1066
1067 .. code-block:: python
1068
1069 await Band.insert(
1070 Band(name="Pythonistas", popularity=500, manager=1)
1071 )
1072
1073 """
1074 query = Insert(table=cls).returning(cls._meta.primary_key)
1075 if rows:
1076 query.add(*rows)
1077 return query
1078
1079 @classmethod
1080 def raw(cls, sql: str, *args: Any) -> Raw:

Callers 15

__init_subclass__Method · 0.80
saveMethod · 0.80
mainFunction · 0.80
get_migration_modulesMethod · 0.80
run_migrationsMethod · 0.80
populateFunction · 0.80
load_json_stringFunction · 0.80
_runMethod · 0.80
setupFunction · 0.80
insertFunction · 0.80
test_cleanMethod · 0.80

Calls 3

InsertClass · 0.90
returningMethod · 0.45
addMethod · 0.45

Tested by 15

test_cleanMethod · 0.64
run_testMethod · 0.64
test_updateMethod · 0.64
test_distinct_onMethod · 0.64
test_havingMethod · 0.64
test_countMethod · 0.64
test_count_whereMethod · 0.64
test_count_distinctMethod · 0.64
test_insertMethod · 0.64
test_addMethod · 0.64