How to loop through a SQL query and return different logs depending on the output of the query?

I am totally new to Python. I have a requirement to run a select query to get the details like User_id and Status from a table like

select User_id , Status from user_details;

Now, there can be either 2 values that will be returned for Status , e.g(true or false).
If value of status is true I have to log something for example:

Status for <User_id> is true

Otherwise,
Status for <User_id> is false.

Also, I will have to check for the unique User_id values.Also the code has to be compatible for both Python version 2 and Python version 3 .How to do that?

  • 1

    Step by step: Retrieve status, log status, check for user id (whatever this exactly means). If you have a specific issue while solving this yourself you can ask here with your code.

    – 

  • I recommend you ask one question at a time. The idea of this site is to be a resource that helps future users to find specific answers to specific questions. For example, if your one question was “How can I write code that is compatible with python 2 and 3?” Then someone can point you to an post like (stackoverflow.com/questions/30422535/…

    – 




Leave a Comment