Advertisement
guthypeter

Untitled

Mar 31st, 2015
1,633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys, cx_Oracle
  4.  
  5. db = cx_Oracle.connect(username, password, db_url)
  6.  
  7. ca = db.cursor()
  8. sch = ca.execute(ca.prepare("select username from all_users where username in ('HR', 'OTHER_SCHEMA') order by username")).fetchall()
  9.  
  10. q = c.prepare('select fetch_schema_metadata(:1) as text from dual')
  11. for schema in [x[0] for x in sch]:
  12.         c = db.cursor()
  13.         res = c.execute(q, [schema.upper(), ])
  14.         f = open('sql/%s.sql' % (schema), 'w')
  15.         f.write(res.fetchall()[0][0].read())
  16.         f.close()
  17.         c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement