First Check
Commit to Help
Example Code
# parse selections and generate a lookup query
for sel in selection:
if sel[1] and not sel[1] == "all":
name = sel[0].replace("sel_", "")
val = sel[1]
if name == "customer":
query = query.filter(Xconnect.customer == int(val))
if name == "region":
query = query.filter(Xconnect.region == int(val))
if name == "lvc":
query = query.filter(Xconnect.lvc == str(val))
if name == "id":
query = query.filter(Xconnect.id == int(val))
if name == "conn_status":
query = query.filter(Xconnect.conn_status == int(val))
if name == "environment":
query = query.filter(Xconnect.environment == int(val))
if name == "client_type":
query = query.filter(Xconnect.client_type == int(val))
if name == "vendor":
query = query.filter(Xconnect.vendor == int(val))
if name == "comp_id":
query = query.filter(Xconnect.comp_id == int(val))
Description
Hello, I have a select field to search for DB records based on some fields, table is called Xconnect,
how do I translate a lookup string into a SQLModel object w/o using constant If/Then blocks?
is there a better way to do this than explicit if/then statements?
for example if someone searches Xconnect table where client_type == "abc"
how can I translate this into a SQL model query w/o using explicit if/then mapping, ie
if name == "client_type":
query = query.filter(Xconnect.client_type == int(val))
Operating System
Linux
Operating System Details
Ubuntu 20.04
SQLModel Version
0.0.6
Python Version
3.8
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Hello, I have a select field to search for DB records based on some fields, table is called Xconnect,
how do I translate a lookup string into a SQLModel object w/o using constant If/Then blocks?
is there a better way to do this than explicit if/then statements?
for example if someone searches Xconnect table where client_type == "abc"
how can I translate this into a SQL model query w/o using explicit if/then mapping, ie
Operating System
Linux
Operating System Details
Ubuntu 20.04
SQLModel Version
0.0.6
Python Version
3.8
Additional Context
No response