Tags: pytho cursor data any object database connection database object CHM Connect
1. Import Sqlite3 database module, from python2.5, sqlite3 become built-in module, do not need additional installation, only need to import.
2. Create/Open Database
- To open a database by using the Connect method
con = sqlite3.connect(‘D:\test.db‘)
- Not only can you create database files on your hard disk, but you can also create them in memory.
con = sqlite3.connect(‘:memory:‘)
3. Database Connection objects
- The Con object is returned by the Connect method above. That is, the database object, which provides the following methods:
- The cursor () method is used to create a cursor object
- Commit () method for transaction commit
- The rollback () method is used to rollback a transaction
- The close () method is used to close a database connection
4. Use of Cursor objects
Python Operation SQLite