API Reference¶
Connection¶
-
aiosqlite.
connect
(database: Union[str, pathlib.Path], *, loop: Optional[asyncio.events.AbstractEventLoop] = None, **kwargs: Any) → aiosqlite.core.Connection¶ Create and return a connection proxy to the sqlite database.
-
class
aiosqlite.
Connection
(connector: Callable[], sqlite3.Connection], loop: Optional[asyncio.events.AbstractEventLoop] = None)¶ Bases:
threading.Thread
-
async
__aenter__
() → aiosqlite.core.Connection¶
-
__await__
() → Generator[Any, None, aiosqlite.core.Connection]¶
-
async
backup
(target: Union[Connection, sqlite3.Connection], *, pages: int = 0, progress: Optional[Callable[[int, int, int], None]] = None, name: str = 'main', sleep: float = 0.25) → None¶ Make a backup of the current database to the target database.
Takes either a standard sqlite3 or aiosqlite Connection object as the target.
-
async
create_function
(name: str, num_params: int, func: Callable) → None¶ Create user-defined function that can be later used within SQL statements. Must be run within the same thread that query executions take place so instead of executing directly against the connection, we defer this to run function.
-
async
cursor
() → aiosqlite.cursor.Cursor¶ Create an aiosqlite cursor wrapping a sqlite3 cursor object.
-
async
execute
(sql: str, parameters: Iterable[Any] = None) → aiosqlite.cursor.Cursor¶ Helper to create a cursor and execute the given query.
-
async
execute_fetchall
(sql: str, parameters: Iterable[Any] = None) → Iterable[sqlite3.Row]¶ Helper to execute a query and return all the data.
-
async
execute_insert
(sql: str, parameters: Iterable[Any] = None) → Optional[sqlite3.Row]¶ Helper to insert and get the last_insert_rowid.
-
async
executemany
(sql: str, parameters: Iterable[Iterable[Any]]) → aiosqlite.cursor.Cursor¶ Helper to create a cursor and execute the given multiquery.
-
async
executescript
(sql_script: str) → aiosqlite.cursor.Cursor¶ Helper to create a cursor and execute a user script.
-
iterdump
() → AsyncIterator[str]¶ Return an async iterator to dump the database in SQL text format.
Example:
async for line in db.iterdump(): ...
-
property
in_transaction
¶
-
property
isolation_level
¶
-
property
row_factory
¶
-
property
text_factory
¶
-
property
total_changes
¶
-
async
Cursors¶
-
class
aiosqlite.cursor.
Cursor
(conn: Connection, cursor: sqlite3.Cursor)¶ Bases:
object
-
async
__aenter__
()¶
-
async
__aexit__
(exc_type, exc_val, exc_tb)¶
-
__aiter__
() → aiosqlite.cursor.Cursor¶ The cursor proxy is also an async iterator.
-
async
__anext__
() → sqlite3.Row¶ Use cursor.fetchone() to provide an async iterable.
-
async
execute
(sql: str, parameters: Iterable[Any] = None) → aiosqlite.cursor.Cursor¶ Execute the given query.
-
async
executemany
(sql: str, parameters: Iterable[Iterable[Any]]) → aiosqlite.cursor.Cursor¶ Execute the given multiquery.
-
async
executescript
(sql_script: str) → aiosqlite.cursor.Cursor¶ Execute a user script.
-
async
fetchall
() → Iterable[sqlite3.Row]¶ Fetch all remaining rows.
-
async
fetchmany
(size: int = None) → Iterable[sqlite3.Row]¶ Fetch up to cursor.arraysize number of rows.
-
async
fetchone
() → Optional[sqlite3.Row]¶ Fetch a single row.
-
property
arraysize
¶
-
property
connection
¶
-
property
description
¶
-
property
lastrowid
¶
-
property
rowcount
¶
-
async
Errors¶
-
exception
aiosqlite.
DatabaseError
¶ Bases:
sqlite3.Error
-
exception
aiosqlite.
IntegrityError
¶ Bases:
sqlite3.DatabaseError
-
exception
aiosqlite.
ProgrammingError
¶ Bases:
sqlite3.DatabaseError
-
exception
aiosqlite.
OperationalError
¶ Bases:
sqlite3.DatabaseError
-
exception
aiosqlite.
NotSupportedError
¶ Bases:
sqlite3.DatabaseError