Engines
Sync Engine
Bases: BaseEngine
The sync engine that uses sqlite3.Connection
and sqlite3.Cursor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
a pathlike object that points to the sqlite database |
required |
enable_foreing_keys |
bool
|
specifies if the pragma should be enforced. Defaults to False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
path |
str
|
the path to the db |
schemas |
set[str]
|
a set of table schemas |
tables_created |
set[str]
|
the tables that have been setup by the engine |
enable_foreing_keys |
bool
|
if True, the engine enables the pragma on all connections |
Source code in ardilla/engine.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
crud(Model)
returns a Crud instances for the given model type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Model |
type[M]
|
the model type for the crud object |
required |
Returns:
Type | Description |
---|---|
Crud[M]
|
Crud[M]: the crud for the model type |
Source code in ardilla/engine.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_connection()
Gets the connections or makes a new one but it doesn't set it as an attrib
Returns:
Type | Description |
---|---|
sqlite3.Connection
|
sqlite3.Connection: the connection |
Source code in ardilla/engine.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Async Engine
Bases: BaseEngine
Async Engine that uses aiosqlite.Connection
and aiosqlite.Cursor
Source code in ardilla/asyncio/engine.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
__aenter__()
async
Stablishes the connection and if specified enables foreign keys pragma
Returns:
Type | Description |
---|---|
AsyncEngine
|
The connection |
Source code in ardilla/asyncio/engine.py
51 52 53 54 55 56 57 58 |
|
__aexit__(*_)
async
Closes the connection
Source code in ardilla/asyncio/engine.py
60 61 62 |
|
connect()
async
Stablishes a connection to the database
Returns:
Type | Description |
---|---|
aiosqlite.Connection
|
The connection |
Source code in ardilla/asyncio/engine.py
35 36 37 38 39 40 41 42 43 44 |
|
crud(Model)
async
This function works exactly like Engine.crud
but
returns an instance of ardilla.asyncio.crud.AsyncCrud
instead of ardilla.crud.Crud
and is asynchronous
Returns:
Type | Description |
---|---|
AsyncCrud[M]
|
The async Crud for the given model |
Source code in ardilla/asyncio/engine.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_connection()
async
Gets the connections or makes a new one but it doesn't set it as an attrib
Returns:
Type | Description |
---|---|
aiosqlite.Connection
|
sqlite3.Connection: the connection |
Source code in ardilla/asyncio/engine.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|