0

Am trying to print multiple rows with the return statement, but it is printing only one record.

def extract(self):
    data = self.oracle_conn().execute('select * from employees').fetchall()
    for row in data:
        
        return row

enter image description here

Any suggestion will be helpful to print multiple lines without using pandas

6
  • Use the print(row) to print rows.. your code will return the first row because return exits the function, returning the value to the caller. Commented Sep 13, 2022 at 13:50
  • I actually need to pass the return value to another function, that's the reason i need it as return value Commented Sep 13, 2022 at 13:52
  • return the data not row Commented Sep 13, 2022 at 13:52
  • 1
    data already contains all rows, just return data. Commented Sep 13, 2022 at 13:53
  • 1
    If the suggestion from Luis is not sufficient, use an example to demonstrate what you are trying to do! Commented Sep 13, 2022 at 14:19

1 Answer 1

1
def extract(self):
    data = self.oracle_conn().execute('select * from employees').fetchall()
    for row in data:
        yield row
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.