I am utilising a specialised collection of tools in Python
to retrieve content from a graph database based on a query provided by the user - the query is mycode
. Here, when I execute the print()
statement like this-
print(graph.run(mycode).to_table())
There can be occasions when there is nothing printed on the console at all (i.e. a blank output), while on other occasions, the print()
statement has values printed onto the output console. I was wondering if there is a way to create conditionals that - when there is no output produced by the print()
statement displays to the user No content found in the DB
. Else, if content is found in the database, it just shows the usual print()
output.
Something of this sort (in terms of pseudo-code) -
if(output of print(graph.run(mycode).to_table()) is blank/empty):
print("No content found in the DB)
else:
print("Content found in the DB! \n")
print(graph.run(mycode).to_table()
Any help and suggestions to achieve this would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire