florist.api.db.client_entities module¶
Definitions for the SQLIte database entities (client database).
- class ClientDAO(uuid, log_file_path=None, pid=None)[source]¶
Bases:
EntityDAO
Data Access Object (DAO) for the Client SQLite entity.
- classmethod from_json(json_data)[source]¶
Convert from a JSON string into an instance of Client.
- Parameters:
json_data (
str
) – the client’s data as a JSON string.- Return type:
Self
- Returns:
(Self) and instancxe of ClientDAO populated with the JSON data.
- table_name = 'Client'¶
- class EntityDAO(uuid)[source]¶
Bases:
ABC
Base Data Access Object (DAO) for SQLite entities.
- abstract __init__(uuid)[source]¶
Initialize an Entity.
Abstract method to be implemented by the child classes.
- Parameters:
uuid (
str
) – the UUID of the entity
- db_path = 'florist/api/client.db'¶
- classmethod find(uuid)[source]¶
Find the entity in the database with the given UUID.
- Parameters:
uuid (
str
) – (str) the UUID of the entity.- Return type:
Self
- Returns:
(Self) an instance of the entity.
- Raises:
ValueError – if no such entity exists in the database with given UUID.
- abstract classmethod from_json(json_data)[source]¶
Convert from a JSON string to an instance of the entity.
Abstract method, to be implemented by the child classes.
- Parameters:
json_data (
str
) – (str) the entity data as a JSON string.- Return type:
Self
- Returns:
(Self) and instance of the entity populated with the JSON data.
- classmethod get_connection()[source]¶
Return the SQLite connection object.
Will create the table of the entity in the DB if it doesn’t exist.
- Return type:
- Returns:
(sqlite3.Connection) The SQLite connection object
- save()[source]¶
Save the current entity to the database.
- Return type:
- Will insert a new record if an entity with self.uuid doesn’t yet exist in the database,
will update the database entity at self.uuid otherwise.
- table_name = 'Entity'¶