mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
Allow SQLITE_MAX_VARS to be customized via Database(sqlite_max_vars=...)
This commit is contained in:
parent
7a52214624
commit
7c01b8d588
3 changed files with 59 additions and 7 deletions
|
|
@ -1026,6 +1026,12 @@ The function can accept an iterator or generator of rows and will commit them ac
|
|||
"name": "Name {}".format(i),
|
||||
} for i in range(10000)), batch_size=1000)
|
||||
|
||||
The largest batch that will actually be sent to SQLite is limited by the maximum number of SQL variables allowed in a single query, which defaults to 999. If your copy of SQLite was compiled with a higher ``SQLITE_MAX_VARIABLE_NUMBER`` you can tell ``sqlite-utils`` to use larger batches - and hence run faster - by passing ``sqlite_max_vars=`` to the ``Database()`` constructor:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
db = Database("big.db", sqlite_max_vars=100_000)
|
||||
|
||||
You can skip inserting any records that have a primary key that already exists using ``ignore=True``. This works with both ``.insert({...}, ignore=True)`` and ``.insert_all([...], ignore=True)``.
|
||||
|
||||
You can delete all the existing rows in the table before inserting the new records using ``truncate=True``. This is useful if you want to replace the data in the table.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue