_sqlite3
| Use Case | Command | Description |
|---|---|---|
| ๐ Open database | connect(database) | Open a connection to SQLite database file or :memory: |
| ๐ Execute SQL | cursor.execute(sql) | Execute a single SQL statement |
| ๐ Fetch all rows | cursor.fetchall() | Fetch all rows from resultset |
| ๐ Use context manager | with connect(...) as con: | Auto-commit or rollback on exit |
| ๐พ Commit transaction | con.commit() | Commit pending transaction |
| โฉ๏ธ Rollback transaction | con.rollback() | Rollback to start of transaction |
| ๐ฆ Backup database | con.backup(target) | Make a backup of the database |
| ๐งช Execute script | con.executescript(sql_script) | Execute multiple SQL statements at once |
https://docs.python.org/3.10/library/_sqlite3.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
builtins.Exception
sqlite3.Error
sqlite3.DatabaseError
sqlite3.DataErrorsqlite3.IntegrityErrorsqlite3.InternalErrorsqlite3.NotSupportedErrorsqlite3.OperationalErrorsqlite3.ProgrammingErrorsqlite3.InterfaceErrorsqlite3.Warningbuiltins.object
sqlite3.Connectionsqlite3.Cursorsqlite3.PrepareProtocolsqlite3.RowSQLite database connection object.
Methods defined here:
__call__(self, /, *args, **kwargs) โ Call self as a function.__enter__(self, /) โ Called when the connection is used as a context manager. Returns itself as a convenience to the caller.__exit__(self, type, value, traceback, /) โ Called when the connection is used as a context manager. If there was any exception, a rollback takes place; otherwise we commit.__init__(self, /, *args, **kwargs) โ Initialize self. See help(type(self)) for accurate signature.backup(self, /, target, *, pages=-1, progress=None, name='main', sleep=0.25) โ Makes a backup of the database.close(self, /) โ Close the database connection. Any pending transaction is not committed implicitly.commit(self, /) โ Commit any pending transaction to the database. If there is no open transaction, this method is a no-op.create_aggregate(self, /, name, n_arg, aggregate_class) โ Creates a new aggregate.create_collation(self, name, callback, /) โ Creates a collation function.create_function(self, /, name, narg, func, *, deterministic=False) โ Creates a new function.cursor(...) โ Return a cursor for the connection.enable_load_extension(self, enable, /) โ Enable dynamic loading of SQLite extension modules.execute(...) โ Executes an SQL statement.executemany(self, sql, parameters, /) โ Repeatedly executes an SQL statement.executescript(self, sql_script, /) โ Executes multiple SQL statements at once.interrupt(self, /) โ Abort any pending database operation.iterdump(self, /) โ Returns iterator to the dump of the database in an SQL text format.load_extension(self, name, /) โ Load SQLite extension module.rollback(self, /) โ Roll back to the start of any pending transaction. If there is no open transaction, this method is a no-op.set_authorizer(self, /, authorizer_callback) โ Sets authorizer callback.set_progress_handler(self, /, progress_handler, n) โ Sets progress handler callback.set_trace_callback(self, /, trace_callback) โ Sets a trace callback called for each SQL statement (passed as unicode).Data descriptors defined here:
DataErrorDatabaseErrorErrorIntegrityErrorInterfaceErrorInternalErrorNotSupportedErrorOperationalErrorProgrammingErrorWarningin_transactionisolation_levelrow_factorytext_factorytotal_changesSQLite database cursor class.
Methods defined here:
__init__(self, /, *args, **kwargs) โ Initialize self. See help(type(self)) for accurate signature.__iter__(self, /) โ Implement iter(self).__next__(self, /) โ Implement next(self).close(self, /) โ Closes the cursor.execute(self, sql, parameters=(), /) โ Executes an SQL statement.executemany(self, sql, seq_of_parameters, /) โ Repeatedly executes an SQL statement.executescript(self, sql_script, /) โ Executes multiple SQL statements at once.fetchall(self, /) โ Fetches all rows from the resultset.fetchmany(self, /, size=1) โ Fetches several rows from the resultset. The default value is set by the Cursor.arraysize attribute.fetchone(self, /) โ Fetches one row from the resultset.setinputsizes(self, sizes, /) โ Required by DB-API. Does nothing in sqlite3.setoutputsize(self, size, column=None, /) โ Required by DB-API. Does nothing in sqlite3.Data descriptors defined here:
arraysizeconnectiondescriptionlastrowidrow_factoryrowcountAll exception classes inherit from builtins.Exception. The hierarchy is shown above in the class tree. Each exception class inherits the following methods and data descriptors from builtins.Exception:
__init__, __new__, __delattr__, __getattribute__, __reduce__, __repr__, __setattr__, __setstate__, __str__, with_traceback__cause__, __context__, __dict__, __suppress_context__, __traceback__, argsAdditionally, sqlite3.Error defines a data descriptor __weakref__ which is inherited by all its subclasses (DatabaseError, InterfaceError, and their subclasses). sqlite3.Warning directly inherits from builtins.Exception and also has __weakref__ defined.
PEP 246 style object adaption protocol type.
Methods defined here:
__init__(self, /, *args, **kwargs) โ Initialize self. See help(type(self)) for accurate signature.Methods defined here:
__eq__(self, value, /) โ Return self==value.__ge__(self, value, /) โ Return self>=value.__getitem__(self, key, /) โ Return self[key].__gt__(self, value, /) โ Return self>value.__hash__(self, /) โ Return hash(self).__iter__(self, /) โ Implement iter(self).__le__(self, value, /) โ Return self<=value.__len__(self, /) โ Return len(self).__lt__(self, value, /) โ Return self<value.__ne__(self, value, /) โ Return self!=value.keys(self, /) โ Returns the keys of the row.Static methods defined here:
__new__(*args, **kwargs) from builtins.type โ Create and return a new object. See help(type) for accurate signature.Adapt given object to given protocol.
Checks if a string contains a complete SQL statement.
connect(database[, timeout, detect_types, isolation_level,
check_same_thread, factory, cached_statements, uri])
Opens a connection to the SQLite database file database. You can use :memory: to open a database connection to a database that resides in RAM instead of on disk.
Enable or disable callback functions throwing errors to stderr.
Enable or disable shared cache mode for the calling thread.
This method is deprecated and will be removed in Python 3.12. Shared cache is strongly discouraged by the SQLite 3 documentation. If shared cache must be used, open the database in URI mode using the cache=shared query parameter.
Register a function to adapt Python objects to SQLite values.
Register a function to convert SQLite values to Python objects.
PARSE_COLNAMES = 2PARSE_DECLTYPES = 1SQLITE_ALTER_TABLE = 26SQLITE_ANALYZE = 28SQLITE_ATTACH = 24SQLITE_CREATE_INDEX = 1SQLITE_CREATE_TABLE = 2SQLITE_CREATE_TEMP_INDEX = 3SQLITE_CREATE_TEMP_TABLE = 4SQLITE_CREATE_TEMP_TRIGGER = 5SQLITE_CREATE_TEMP_VIEW = 6SQLITE_CREATE_TRIGGER = 7SQLITE_CREATE_VIEW = 8SQLITE_CREATE_VTABLE = 29SQLITE_DELETE = 9SQLITE_DENY = 1SQLITE_DETACH = 25SQLITE_DONE = 101SQLITE_DROP_INDEX = 10SQLITE_DROP_TABLE = 11SQLITE_DROP_TEMP_INDEX = 12SQLITE_DROP_TEMP_TABLE = 13SQLITE_DROP_TEMP_TRIGGER = 14SQLITE_DROP_TEMP_VIEW = 15SQLITE_DROP_TRIGGER = 16SQLITE_DROP_VIEW = 17SQLITE_DROP_VTABLE = 30SQLITE_FUNCTION = 31SQLITE_IGNORE = 2SQLITE_INSERT = 18SQLITE_OK = 0SQLITE_PRAGMA = 19SQLITE_READ = 20SQLITE_RECURSIVE = 33SQLITE_REINDEX = 27SQLITE_SAVEPOINT = 32SQLITE_SELECT = 21SQLITE_TRANSACTION = 22SQLITE_UPDATE = 23adapters = {}converters = {}sqlite_version = '3.37.2'version = '2.6.0'/usr/lib/python3.10/lib-dynload/_sqlite3.cpython-310-x86_64-linux-gnu.so
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 15:49 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)