Database¶
db
¶
This module defines helper functions to create, connect and manage the Mirumoji
database for storing profile information using the databases
and SQLAlchemy
modules with SQLite3.
Attributes:
Name | Type | Description |
---|---|---|
DATABASE_URL |
str
|
|
METADATA |
MetaData
|
|
database |
Database
|
|
engine |
Engine
|
|
DbManager
¶
Implements async CRUD operations for the mirumoji database.
Attributes:
Name | Type | Description |
---|---|---|
TABLES |
dict
|
Dictionary mapping string table names to their
|
create(table_name, values)
async
¶
delete(table_name, filter_dict)
async
¶
Delete row where column filter_dict.key
has value
filter_dict.value
, in table table_name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
Table name to update |
required |
filter_dict
|
Dict[str, Any]
|
Dictionary of |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
Return result of |
execute(q)
async
¶
read(table_name, filter_dict, fetch_one=False)
async
¶
Select all rows where column filter_dict.key
has value
filter_dict.value
, in table table_name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
Table name to update |
required |
filter_dict
|
Dict[str, Any]
|
Dictionary of |
required |
fetch_one
|
bool
|
If True, fetch only one result otherwise fetch all. Defaults to False |
False
|
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
Result of |
update(table_name, filter_dict, values)
async
¶
Update row where columns filter_dict.key
have value
filter_dict.value
, in table table_name
with values values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
Table name to update |
required |
filter_dict
|
Dict[str, Any]
|
Dictionary of |
required |
values
|
dict
|
New row values |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
Return result of |
connect_db()
async
¶
Wrapper for Database.connect
disconnect_db()
async
¶
Wrapper for Database.disconnect
get_db()
async
¶
Get the Database object.
Returns:
Name | Type | Description |
---|---|---|
Database |
Database
|
|
Tables
¶
This module defines the Tables of the Mirumoji Database for profile management.
Attributes:
Name | Type | Description |
---|---|---|
METADATA |
MetaData
|
Database MetaData object. |
profiles |
Table
|
sqalchemy table object for profiles. |
gpt_templates |
Table
|
sqalchemy table object for gpt_templates. |
profile_transcripts |
Table
|
sqalchemy table object for transcripts. |
profile_files |
Table
|
sqalchemy table object for files. |
clips |
Table
|
sqalchemy table object for saved clips. |