1、- 1 - 外文原文 The Connection Lifecycle Connections are the sole means through which to operate on a database. The connection lifecycle consists of three phases: 1. Connect to the database. Connecting involves creating a database connection object of some sort. The connection object manages transactions
2、 (through its associated pager), often performs simple one-step queries (using the wrapped query functions), and creates statement objects for prepared queries. 2. Perform transactions. As you know, all commands are executed within transactions. By default, a database connection runs in autocommit m
3、ode. This means that every SQL command it executes runs under its own independent transaction. The alternative is to manually declare transactions using BEGINCOMMIT. In this scenario, multiple commands can run together within the same transaction. 3. Disconnect from the database. Disconnecting from
4、a database involves closing the database file and the files of any attached databases. Other activities involved with query processing include handling errors, busy conditions, and schema changes, all of which are done through the utility functions covered in the following sections. Connecting to a Database Connecting to a database involves little more than opening a file. Every SQLite database is stored in a single operating system fileone database to one file. The function used to connect,