Python Forum
Database table structure compare(Oracle)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database table structure compare(Oracle)
#1
Hi,

I am new to python.

i am trying to compare structures of 2 similar tables from python(connecting to Oracle DB). i was able to connect and run the select. i need help with next steps(compare). i am not expecting code. if you can give me a general idea on how to do it will be great!

Thanks
Gopal
Reply
#2
would you please share your code, so the problem can be seen in context.
Reply
#3
import cx_Oracle

dsn = cx_Oracle.makedsn('servername',6136,'ABCD')

print (dsn)

conn=cx_Oracle.connect("userid","pwd",dsn)
curs = conn.cursor()

curs.execute("select table_name,column_name from ALL_tab_columns where OWNER='userid' order by table_name")
by running the above code i create a base table/file in python

i run the same code next day and want to compare this result to the above table/file.
Reply
#4
This code selects the structure of all existing tables owned by userid.
It's not creating anything.
Reply
#5
with open(file_path, "w", newline='') as csv_file: # Python 3 version
csv_writer = csv.writer(csv_file)
csv_writer.writerow([i[0] for i in curs.description]) # write headers
csv_writer.writerows(curs)


hope this clears you question.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use pandas to compare two DataFrames having different structure traja47 0 751 Sep-24-2022, 08:07 AM
Last Post: traja47
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,116 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,562 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  Load data from One oracle Table to Multiple tables amy83 1 1,743 Dec-02-2020, 01:57 AM
Last Post: Larz60+
  Fetch Oracle DB rows & print it in HTML file with table's col headers in table format tssr_2001 1 2,922 Sep-04-2020, 01:39 PM
Last Post: ibreeden
  Load table from Oracle to MYSQL using python himupant94 0 1,611 May-12-2020, 04:50 PM
Last Post: himupant94
  Database structure (no code?) BlackmoreSteve620721 1 1,800 Apr-13-2020, 10:39 PM
Last Post: Larz60+
  How to compare in python an input value with an hashed value in mysql table? Formationgrowthhacking 4 3,267 Jan-14-2020, 11:43 AM
Last Post: Formationgrowthhacking
  MYSQL how to assign a table for each user in my username table database? YoshikageKira 1 2,764 Dec-26-2019, 05:57 AM
Last Post: buran
  How read Table Structure from Database nnsatpute 5 3,661 Oct-25-2019, 10:08 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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