I created a postgres function and saved in a file called get_data.sql
create or replace function getalldata(entryDate TIMESTAMP, exitDate TIMESTAMP) RETURNS SETOF employee AS $$ BEGIN begin -- try select employee.name, dept.name from employee join dept on employee.dept_id=dept.id where employee.name='Kumar' and employee.timestamp>=entryDate and employee.timestamp<=exitDate; exception when others then raise notice 'The transaction is in an uncommittable state. ''Transaction was rolled back'; raise notice '% %', SQLERRM, SQLSTATE; end ; -- try..catch END; $$ LANGUAGE plpgsql;I run this sql file in sqlalchemy
try: from sqlalchemy import create_engine, text connection = engine.connect() with open('get_data.sql', 'r') as file: procedure_sql = file.read() procedure_sql = text(procedure_sql) results = connection.execute( procedure_sql, {'entryDate':start_datetime, 'exitDate':end_datetime} ) results = list(results.fetchall()) except Exception as e: print('error', e)But I got this error
error This result object does not return rows. It has been closed automatically.
How to solve this issue, and which causes this error