Working on contact create update v4
This commit is contained in:
@@ -1024,4 +1024,38 @@ def lookup_id_random_pop(obj_data:dict):
|
||||
obj_data.pop('from_object_id_random')
|
||||
|
||||
return obj_data
|
||||
# ### END ### API DB SQL ### lookup_id_random_pop() ###
|
||||
# ### END ### API DB SQL ### lookup_id_random_pop() ###
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API DB SQL Methods ### get_account_id_w_for_type_id() ###
|
||||
# Updated 2021-08-24
|
||||
def get_account_id_w_for_type_id(
|
||||
for_type: str,
|
||||
for_id: int|str,
|
||||
) -> bool|int|None:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if for_id := redis_lookup_id_random(record_id_random=for_id, table_name=for_type): pass
|
||||
else: return False
|
||||
|
||||
data = {}
|
||||
data['for_type'] = for_type
|
||||
data['for_id'] = for_id
|
||||
|
||||
sql = f"""
|
||||
SELECT `for`.id AS 'for_id', `for`.id_random AS 'for_id_random', `for`.account_id AS account_id
|
||||
FROM :for_type AS `for`
|
||||
WHERE `for`.id = :for_id
|
||||
LIMIT 1;
|
||||
"""
|
||||
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
if for_data_result := sql_select(data=data, sql=sql):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(for_data_result)
|
||||
if account_id := for_data_result.get('account_id', None): return account_id
|
||||
else: return False
|
||||
else: return None
|
||||
# ### END ### API DB SQL Methods ### get_account_id_w_for_type_id() ###
|
||||
Reference in New Issue
Block a user