Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys, cx_Oracle
- db = cx_Oracle.connect(username, password, db_url)
- ca = db.cursor()
- sch = ca.execute(ca.prepare("select username from all_users where username in ('HR', 'OTHER_SCHEMA') order by username")).fetchall()
- q = c.prepare('select fetch_schema_metadata(:1) as text from dual')
- for schema in [x[0] for x in sch]:
- c = db.cursor()
- res = c.execute(q, [schema.upper(), ])
- f = open('sql/%s.sql' % (schema), 'w')
- f.write(res.fetchall()[0][0].read())
- f.close()
- c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement