![]() |
ThalamOS
a powerful Flask web application designed to enhance your storage management.
|
Functions | |
None | setup () |
None | fetch_csv () |
Annotated[tuple, "tuple containing the item's data if found, otherwise None"] | fetch_item (item_id) |
None | delete_item (item_id) |
None | create_item (pos, obj_type, name, json_data) |
Annotated[ list, "list of tuples containing the rows from the database that match the search criteria",] | search (search_term) |
None | update_item (item_id, pos, obj_type, name, json_data) |
Variables | |
Annotated | db_path |
Annotated | mydb |
Annotated | cursor = mydb.cursor() |
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. Functions: - setup(): Sets up the database by creating the 'storage' table and a trigger for automatic updating of the 'modification_time' column. - fetch_csv(): Fetches all data from the 'storage' table and writes it to a CSV file named 'out.csv'. - fetch_item(item_id): Fetches an item from the storage database by its id. - delete_item(item_id): Deletes an item from the storage database based on the provided item id. - create_item(pos, typ, name, jsonData): Creates an item in the storage database. - search(search_term): Searches the storage database for entries that match the given search term.
None Storage_connector.create_item | ( | pos, | |
obj_type, | |||
name, | |||
json_data ) |
Creates an item in the storage database. Args: pos (int): The position of the item. typ (str): The type of the item. name (str): The name of the item. jsonData (str): The JSON data associated with the item. If empty JSON object ("{}"), no additional info is stored. Returns: None
Definition at line 128 of file Storage_connector.py.
None Storage_connector.delete_item | ( | item_id | ) |
Deletes an item from the storage database based on the provided item id. Args: itemID (int): The id of the item to be deleted from the storage. Returns: None
Definition at line 115 of file Storage_connector.py.
None Storage_connector.fetch_csv | ( | ) |
Fetches all data from the 'storage' table in the database and writes it to a CSV file named 'out.csv'. The function executes a SQL query to select all rows from the 'storage' table, writes the column headers and all rows to the CSV file, and saves the file with UTF-8 encoding. Raises: Any exceptions raised by the database cursor execution or file operations.
Definition at line 82 of file Storage_connector.py.
Annotated[tuple, "tuple containing the item's data if found, otherwise None"] Storage_connector.fetch_item | ( | item_id | ) |
Fetch an item from the storage database by its id. Args: itemID (int): The id of the item to fetch. Returns: tuple: A tuple containing the item's data if found, otherwise None.
Definition at line 100 of file Storage_connector.py.
Annotated[ list, "list of tuples containing the rows from the database that match the search criteria", ] Storage_connector.search | ( | search_term | ) |
Searches the storage database for entries that match the given search term. Args: searchTerm (str): 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: list: 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 159 of file Storage_connector.py.
None Storage_connector.setup | ( | ) |
Sets up the database by creating the 'storage' table and a trigger for automatic updating of the 'modification_time' column. The 'storage' table contains the following columns: - id: INTEGER, primary key, autoincrement - position: INTEGER - type: sensor | screw | display | nail | display | cable | miscellaneous | Motor Driver - name: TEXT - info: TEXT - modification_time: TIMESTAMP, defaults to the current timestamp The trigger 'update_modification_time' ensures that the 'modification_time' column is automatically updated to the current timestamp whenever a row in the 'storage' table is updated. Commits the changes to the database and prints a confirmation message.
Definition at line 36 of file Storage_connector.py.
None Storage_connector.update_item | ( | item_id, | |
pos, | |||
obj_type, | |||
name, | |||
json_data ) |
Updates an item in the storage database. Args: item_id (int): The id of the item to update. pos (int): The new position of the item. obj_type (str): The new type of the item. name (str): The new name of the item. json_data (str): The new JSON data associated with the item. Returns: None
Definition at line 208 of file Storage_connector.py.
Annotated Storage_connector.cursor = mydb.cursor() |
Definition at line 33 of file Storage_connector.py.
Annotated Storage_connector.db_path |
Definition at line 26 of file Storage_connector.py.
Annotated Storage_connector.mydb |
Definition at line 30 of file Storage_connector.py.