luka Good day 🙂
Here's your Python code with modifications:
import sql_query
import catalogs
(Create a list of fields we want to retrieve)
fields = ["Id", "Email", "Name"]
(GUID of the component)
component = 'cee394d2-64fd-49d0-9221-1068ae010495'
(Dictionary of fields and their values for filtering using WHERE)
filter_fields = {'Email': 'email', 'Id': 1, 'Field': None}
(To get the NOT EQUAL operator, place the value in a tuple)
filter_fields = {'Email': 'email', 'Id': (1,), 'Field': (None,)}
(Get the SQL query as a string)
query_str = sql_query.filter_query(fields, component, filter_fields)
(Create the query)
query = catalogs.query(query_str)
(Execute the query)
item["query_result"] = query.execute()
(Result)
"""
SELECT cmp."Id" as "Id",
cmp."Data_Email" as "Email",
cmp."Data_Name" as "Name"
FROM "cee394d2-64fd-49d0-9221-1068ae010495" as cmp
WHERE cmp."Data_Email" = 'email' AND cmp."Id" <> 1 AND cmp."Data_Field" IS NOT NULL
"""