![]() |
ThalamOS
a powerful Flask web application designed to enhance your storage management.
|
Functions | |
| setup () | |
| StorageItem|None | fetch_item (int item_id) |
| None | delete_item (int item_id) |
| None | create_item (int pos, StorageItemType obj_type, str name, str json_data) |
| List[StorageItem] | search (str search_term) |
| None | update_item (int item_id, int pos, StorageItemType obj_type, str name, str json_data) |
Variables | |
| base_dir = os.path.dirname(__file__) | |
| db_dir = os.path.join(base_dir, "data") | |
| db_path = os.path.join(db_dir, "storage.db") | |
| engine = create_engine(f"sqlite:///{db_path}", connect_args={"check_same_thread": False}) | |
StorageConnector Module This module provides functions to interact with a SQLite database for managing storage items. It includes functionalities to set up the database, create, fetch, delete, and search items, as well as export the data to a CSV file.
| None Storage_connector.create_item | ( | int | pos, |
| StorageItemType | obj_type, | ||
| str | name, | ||
| str | json_data ) |
Creates a new item in the storage database with the provided position, type, name, and JSON data.
Args:
pos: LED position of the item.
obj_type: type of the Item
name: name of item
json_data: additional json ifno
Returns:
Definition at line 60 of file Storage_connector.py.
| None Storage_connector.delete_item | ( | int | item_id | ) |
Deletes an item from the storage database based on the provided item id.
Args:
item_id: The id of the item to be deleted from the storage.
Returns:
None
Definition at line 42 of file Storage_connector.py.
| StorageItem | None Storage_connector.fetch_item | ( | int | item_id | ) |
Fetch an item from the storage database by its id.
Args:
item_id: The id of the item to fetch.
Returns:
The item object if found, otherwise None.
Definition at line 30 of file Storage_connector.py.
| List[StorageItem] Storage_connector.search | ( | str | search_term | ) |
Searches the storage database for entries that match the given search term.
Args:
search_term: The term to search for in the database. The term will be split
into individual words,
and each word will be used to search the 'type', 'name', and
'info' columns.
Returns:
A list of tuples containing the rows from the database that match the search criteria.
Returns None if there is an SQLite programming error.
Raises:
sqlite3.ProgrammingError: If there is an error executing the query.
Definition at line 87 of file Storage_connector.py.
| Storage_connector.setup | ( | ) |
Sets up the database by creating the necessary tables if they do not already exist.
Definition at line 26 of file Storage_connector.py.
| None Storage_connector.update_item | ( | int | item_id, |
| int | pos, | ||
| StorageItemType | obj_type, | ||
| str | name, | ||
| str | json_data ) |
Updates an item in the storage database.
Args:
item_id: The id of the item to update.
pos: The new position of the item.
obj_type: The new type of the item.
name: The new name of the item.
json_data: The new JSON data associated with the item.
Definition at line 119 of file Storage_connector.py.
| Storage_connector.base_dir = os.path.dirname(__file__) |
Definition at line 15 of file Storage_connector.py.
| Storage_connector.db_dir = os.path.join(base_dir, "data") |
Definition at line 16 of file Storage_connector.py.
| Storage_connector.db_path = os.path.join(db_dir, "storage.db") |
Definition at line 17 of file Storage_connector.py.
| Storage_connector.engine = create_engine(f"sqlite:///{db_path}", connect_args={"check_same_thread": False}) |
Definition at line 24 of file Storage_connector.py.