NOTICE: All information contained herein is, and remains
the property of TechnoCore.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore.
The ObjProcessText class within ObjTextLookup.py is a specialized text processor designed to perform dynamic SQL lookups. It constructs a SQL query from a given template and a set of parameters, executes the query, and returns the result.
ObjProcessTextInherits from ObjData.ObjData.
__init__(self, db_connection=0, page=0)The constructor initializes the database connection and sets up the page context, from which the server object is derived.
db_connection: An existing database connection object.page: The page object, used to access the server context.process(self, sql_template: str = "", param_1: str = "", ...)This is the core method that executes the lookup.
Parameters:
sql_template (str): A string containing the SQL query to be executed. It should use placeholders like $param1$, $param2$, etc., for dynamic values. The ^ character can be used in place of $.param_1, param_2, ... (str): The values that will replace the corresponding placeholders in the sql_template.Process Flow:
sql_template and ensures it is a SELECT statement.$param1$, $param2$, etc.) with the provided parameter values.self.sql_get_value() method, which returns a single value from the database.self.process_text() before being returned.Returns:
If you want to look up a user's email from a users table based on their ID, you could use the following:
sql_template: "SELECT email FROM users WHERE id = '$param1$'"param_1: "123"The process method would execute the query: SELECT email FROM users WHERE id = '123' and return the corresponding email address.