Python Forum
Fetch Oracle DB rows & print it in HTML file with table's col headers in table format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fetch Oracle DB rows & print it in HTML file with table's col headers in table format
Hi All,

I am new to python. I am using Python 3.6 in Spyder on Windows OS.

Can you please guide on how to achieve the below one's, I need to fetch Oracle DB rows & print it in HTML file with table's column headers in table format :

1. Fetch some 10 or 20 rows & columns using a Oracle select query (example : SELECT * FROM EMP ORDER BY DEPT_ID).

Note : Here, I am able to connect to Oracle DB using cx_Oracle, and execute and print the output in the terminal window

2. Write the fetched rows into a new HTML file.

Note :
a. Tried filewriter.write(SQL), but not able to print the output in the HTML file. Not sure if i need to use any additional libraries to do this step !

b. I am able to do some sample printing like hi, date in HTML file, just to check if i am able to write into HTML file. For formatting purpose, i tried to add some new empty lines into the HTML file, which is not working. print('\n') or print('\\n') or print('\r\n') or filewrite.writer('\n') are not working, also added sys.stdout=filewriter, still not working. Dont know why!?

3. In HTML, the query output should be written, along with table's column headers and this output should be in table format with table borders ( as we see in the GUI Tools like SQL Developer, TOAD, Etc). How to achieve this?

4. Also, interested to know how to give some bold color to only one column alone. Example : Out of 10 columns fetched to display in HTML file, just put RED color for the 4th column alone
You don't show us your code, so it is guessing. Let me start with the problem to write to the file. Have you read: 7.2. Reading and Writing Files?
So what is the problem?
f = open('aa.html', 'a')

Possibly Related Threads…
Thread Author Replies Views Last Post
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 439 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 640 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  Remove Blank Lines from docx table and paragraphs bsudhirk001 1 160 Feb-14-2021, 12:38 AM
Last Post: Larz60+
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 155 Feb-05-2021, 04:37 PM
Last Post: nilamo
  write mariadb table rows query to each file? shams 1 141 Feb-02-2021, 04:10 PM
Last Post: buran
  Convert table in pandas tgottsc1 2 199 Jan-26-2021, 01:58 PM
Last Post: tgottsc1
  How to update values in a pyarrow table? xraphael75 1 249 Jan-25-2021, 02:14 PM
Last Post: xraphael75
  Populate a table with variables Market_Python 4 291 Jan-11-2021, 09:45 AM
Last Post: Pedroski55
  Data extraction from a table based on column and row names tgottsc1 1 294 Jan-09-2021, 10:04 PM
Last Post: buran
  Reading csv with multiple "headers" Clives 3 471 Dec-31-2020, 09:25 AM
Last Post: Ana_junior

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020