NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

database.Database.commit()

Syntax

commit(each=0)

Description

When called without parameters, commits any pending transactions. This means, for example, that records recently appended to a table are written to the database file. It's faster to write records to file in batches of, say, 10 000, than writing each record to the file individually. Batch transactions include the Table append() or remove() commands, or the Database sql() command. When commit() is called with the each parameter, sets the batch size. By default, transactions are commited instantly, but if you plan to add a lot of records at the same time it's better to commit them in batch. See also the close() command.

Example

Add a new page to the book and explicitly commit it:
db = ximport("database")
book = db.create("book")
book.append("pages", ["title", "text", "image", "pagenumber"])
book.pages.append(title="introduction", text="...", pagenumber="1")
book.commit()