0

I have below python script dbreport.py where I am using cx_Oracle module to connect the oracle db and it is working fine.Now I have some sql statements which I want to run and generate the output of that into html report.Mentioning some part of the python script.The issue here is I want to add the below sql to generate the output in html format in below python script function.I am not sure how to achieve this.

######Sql statement to generate html report#######

SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>EMPLOYEE REPORT</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFC6} --> -
</STYLE>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"
spool report2.html
Select * from hr.departments where date = '{}'.format(dt_string)
spool off

#######dbreport.py script##########################

import cx_Oracle

def main(env_name):
    try:
       now datetime.now()
       dt_string = now.strftime("%Y%m%d")
       connection = Connection("ABC_DEV_KK","username", "pass")
       cursor = connection.cursor()
       cursor.execute()---------------------I tried here but not succesfull
       res = cursor.fetchall()
       print(res)
    except Exception as e:
       logging.info(e)


if _name_ == '_main_':
    main()
3
  • have you checked this post ? stackoverflow.com/questions/57876133/… Commented Sep 24, 2021 at 6:11
  • @RobertoHernandez I tried but not getting any success. Commented Sep 24, 2021 at 16:34
  • I don't think even running each command as a cursor.execute will work here.Any yea how can do this? Commented Sep 25, 2021 at 18:05

0

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.