Skip to content

Commit 98cbf46

Browse files
committed
insert_into() example to README
1 parent 3167376 commit 98cbf46

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,20 @@ This produces:
14201420
WHERE "date">NOW()-7
14211421
GROUP BY "col1","col2"
14221422
1423+
Inserting dictionaries
1424+
""""""""""""""""
1425+
1426+
There's a simple convenience function to insert dicts with ``pypika.Query.into("mytable").insert_dict()``.
1427+
1428+
.. code-block:: python
1429+
Query.into(Table("foo")).insert_dict({"value": 42, "created_at": datetime(2024, 3, 15)})
1430+
1431+
This produces:
1432+
1433+
.. code-block:: sql
1434+
INSERT INTO "foo" ("value", "created_at")
1435+
VALUES (42, '2024-03-15T00:00:00')
1436+
14231437
.. _tutorial_end:
14241438

14251439
.. _contributing_start:

0 commit comments

Comments
 (0)