SQLAlchemy: how to incorporate IF ELSE statements (without 'cases')?
I'm trying to check to see if an entry exists in my database with a certain value in order to determine whether or not it needs to be added (using sessions).
Googling around showed me some simple examples of using . \\where 'cases' however I do not think that is what I'm trying to do either. The only thing I could think of off the top of my head is try/except statements (ie. 'try' to find it within the table, 'if' excepts-- do something else) but that seems unnecessarily sloppy.
What's the simplest way to achieve this?
if is_valid is True:
print(extension_type, 'is supported!')
# this doesn't seem to do anything
session.query([SupportedExtensions]). \
where(
case(
/r/flask
https://redd.it/c8t5ar
I'm trying to check to see if an entry exists in my database with a certain value in order to determine whether or not it needs to be added (using sessions).
Googling around showed me some simple examples of using . \\where 'cases' however I do not think that is what I'm trying to do either. The only thing I could think of off the top of my head is try/except statements (ie. 'try' to find it within the table, 'if' excepts-- do something else) but that seems unnecessarily sloppy.
What's the simplest way to achieve this?
if is_valid is True:
print(extension_type, 'is supported!')
# this doesn't seem to do anything
session.query([SupportedExtensions]). \
where(
case(
/r/flask
https://redd.it/c8t5ar