Category: Development

Python row copier

Below is a script I wrote to copy a set of tables from one schema (or database) to another. It simply takes every table in the source schema and builds up an array based copy for it, with the usage…

Gzip in python

We have a large text file containing 325 million integer values that we need to load into a database. The file uncompressed is about 4.5GB. Even though disk is cheap, we didn’t have enough readily available to quickly decompress the…

Dumping Oracle DDL part two

Below is a python script that strip the double quotes from the output of dbms_metadata.get_ddl, as well as the storage clauses. The initial clause is often far too high, so this allows you to extract the DDL and run it…

Running log miner from python

Python is so flexible for quick and dirty toolsets, that I built one this morning that invokes the Oracle log miner software to read archived redo logs. It queries the logs for changes to a given table, and prints any…

Quick way to compare two python lists

***Please read the entire post if you are looking for a fast way to compare two lists*** If you need to compare two lists, you can use a list comprehension such as the following: >>> a=[1,3,5] >>> b=[1,2,3,4,5,6] >>> print…

Python script to print out table data in name/value pairs

Simple today. I just wanted to ensure I had this in case I need to cut and paste it later 🙂 #!/home/oracle/local/bin/python import cx_Oracle, string connection = cx_Oracle.connect(mode = cx_Oracle.SYSDBA) cursor = connection.cursor() cnt=cursor.execute(“select * from v$database”) colcount=len(cnt.description) for row…