Changeset 748 for trunk/docs


Ignore:
Timestamp:
Jan 15, 2016, 9:25:31 AM (4 years ago)
Author:
cito
Message:

Add method truncate() to DB wrapper class

This methods can be used to quickly truncate tables.

Since this is pretty useful and will not break anything, I have
also back ported this addition to the 4.x branch.

Everything is well documented and tested, of course.

Location:
trunk/docs/contents
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/contents/changelog.rst

    r745 r748  
    4949- New methods get_parameters() and set_parameters() in the classic interface
    5050  which can be used to get or set run-time parameters.
     51- New method truncate() in the classic interface that can be used to quickly
     52  empty a table or a set of tables.
    5153- Fix decimal point handling.
    5254- Add option to return boolean values as bool objects.
  • trunk/docs/contents/pg/db_wrapper.rst

    r747 r748  
    477477exist and 1 if the row was deleted).
    478478
     479truncate -- Quickly empty database tables
     480-----------------------------------------
     481
     482.. method:: DB.truncate(self, table, [restart], [cascade], [only]):
     483
     484    Empty a table or set of tables
     485
     486    :param table: the name of the table(s)
     487    :type table: str, list or set
     488    :param bool restart: whether table sequences should be restarted
     489    :param bool cascade: whether referenced tables should also be truncated
     490    :param only: whether only parent tables should be truncated
     491    :type only: bool or list
     492
     493This method quickly removes all rows from the given table or set
     494of tables.  It has the same effect as an unqualified DELETE on each
     495table, but since it does not actually scan the tables it is faster.
     496Furthermore, it reclaims disk space immediately, rather than requiring
     497a subsequent VACUUM operation. This is most useful on large tables.
     498
     499If *restart* is set to `True`, sequences owned by columns of the truncated
     500table(s) are automatically restarted.  If *cascade* is set to `True`, it
     501also truncates all tables that have foreign-key references to any of
     502the named tables.  If the parameter *only* is not set to `True`, all the
     503descendant tables (if any) will also be truncated. Optionally, a ``*``
     504can be specified after the table name to explicitly indicate that
     505descendant tables are included.  If the parameter *table* is a list,
     506the parameter *only* can also be a list of corresponding boolean values.
     507
    479508escape_literal -- escape a literal string for use within SQL
    480509------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.