Python Sqlite3
The sqlite3 module is a database interface library (implementing the DB-API as per PEP 249) for Sqlite.
Contents
-
Python Sqlite3
- Usage
-
Classes
- Blob
-
Connection
- Backup
- BlobOpen
- Close
- Commit
- Cursor
- Create_Aggregate
- Create_Collation
- Create_Function
- Create_Window_Function
- Deserialize
- Enable_Load_Extension
- Execute
- ExecuteMany
- ExecuteScript
- GetLimit
- Interrupt
- In_Transaction
- Isolation_Level
- IterDump
- Load_Extension
- RollBack
- Row_Factory
- Serialize
- SetLimit
- Set_Progress_Handler
- Set_Trace_Callback
- Text_Factory
- Total_Changes
- Cursor
- PrepareProtocol
- Row
- Functions
- Constants
- Exceptions
- See also
Usage
import sqlite3
con = sqlite3.connect("example.db")
cur = con.cursor()
# list tables
for i, n in enumerate(cur.execute("SELECT name FROM sqlite_schema WHERE type='table'")):
print(i, n[0])
# print SQL definition of the 'example' table
sql = list(cur.execute("SELECT sql FROM sqlite_schema WHERE name='example'"))
print(sql[0][0])
# cleanup
con.close()
Classes
Blob
Close
Read
Seek
Tell
Write
Connection
See the example.
Backup
BlobOpen
Close
Commit
Cursor
Create_Aggregate
Create_Collation
Create_Function
Create_Window_Function
Deserialize
Enable_Load_Extension
Execute
ExecuteMany
ExecuteScript
GetLimit
Interrupt
In_Transaction
Isolation_Level
IterDump
Load_Extension
RollBack
Row_Factory
Serialize
SetLimit
Set_Progress_Handler
Set_Trace_Callback
Text_Factory
Total_Changes
Cursor
See the example.
ArraySize
Close
Connection
Description
Execute
ExecuteMany
ExecuteScript
FetchAll
FetchMany
FetchOne
LastRowId
RowCount
Row_Factory
SetInputSizes
SetOutputSize
PrepareProtocol
Row
Keys
Functions
Complete_Statement
Connect
See the example.
Enable_Callback_Tracebacks
Register_Adapter
Register_Converter
Constants
Name |
Meaning |
PARSE_COLNAMES |
|
PARSE_DECLTYPES |
|
SQLITE_OK |
|
SQLITE_DENY |
|
SQLITE_IGNORE |
|
apilevel |
internal implementation detail of DB-API; always "2.0" |
paramstyle |
always "qmark" |
sqlite_version |
runtime version of Sqlite as a string |
sqlite_version_info |
runtime version of Sqlite as an integer tuple |
threadsafety |
|
version |
module version as a string |
version_info |
module version as an integer tuple |
Exceptions
Name |
Meaning |
Warning |
not used by the module but provided for higher-level libraries |
Error |
base class of all below exceptions; adds two attributes (sqlite_errorcode, sqlite_errorname) |
InterfaceError |
|
DatabaseError |
|
DataError |
|
OperationalError |
|
IntegrityError |
|
InternalError |
|
ProgrammingError |
|
NotSupportedError |
|
See also
Python sqlite3 module documentation
