Mercurial > sqlpython
changeset 479:99734f5dded5
(none)
author | catherine@dellzilla |
---|---|
date | Thu, 18 Mar 2010 16:35:19 -0400 |
parents | ad07a08cb792 |
children | e60d9192bfaa |
files | sqlpython/connections.py sqlpython/mysqlpy.py sqlpython/sqlpyPlus.py |
diffstat | 3 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/connections.py Fri Mar 12 19:43:08 2010 -0500 +++ b/sqlpython/connections.py Thu Mar 18 16:35:19 2010 -0400 @@ -27,7 +27,10 @@ def __init__(self, name, dbobj): self.fullname = name self.dbobj = dbobj - self.type = str(type(self.dbobj)).split('.')[-1].lower().strip("'>") + if hasattr(self.dbobj, 'type'): + self.type = self.dbobj.type.lower() + else: + self.type = str(type(self.dbobj)).split('.')[-1].lower().strip("'>") self.path = '%s/%s' % (self.type, self.fullname) if '.' in self.fullname: (self.owner, self.unqualified_name) = self.fullname.split('.')
--- a/sqlpython/mysqlpy.py Fri Mar 12 19:43:08 2010 -0500 +++ b/sqlpython/mysqlpy.py Thu Mar 18 16:35:19 2010 -0400 @@ -49,11 +49,6 @@ SQL> exit ''' - ''' - def do_greet(self, arg): - print 'Hello, ' + arg - ''' - def __init__(self): sqlpyPlus.__init__(self) self.maxtselctrows = 10
--- a/sqlpython/sqlpyPlus.py Fri Mar 12 19:43:08 2010 -0500 +++ b/sqlpython/sqlpyPlus.py Thu Mar 18 16:35:19 2010 -0400 @@ -854,16 +854,21 @@ """Displays source code.""" self._pull(arg, opts) - def _pull(self, arg, opts, vc=None): + def _pull(self, arg, opts, vc=None): opts.exact = True statekeeper = Statekeeper(opts.dump and self, ('stdout',)) (username, gerald_schema) = self.metadata() try: - for description in self._matching_database_objects(arg, opts): + for description in self._matching_database_objects(arg, opts): self.poutput(description.path) txt = description.dbobj.get_ddl() + if hasattr(description.dbobj, 'get_body_ddl'): + bodytxt = description.dbobj.get_body_ddl() + else: + bodytxt = '' if opts.get('lines'): txt = self._with_line_numbers(txt) + bodytxt = self._with_line_numbers(bodytxt) if opts.dump: owner = description.owner or self.current_instance.username path = os.path.join(owner.lower(), description.type.lower()) \ @@ -874,14 +879,24 @@ pass filename = os.path.join(path, '%s.sql' % description.unqualified_name.lower()) self.stdout = open(filename, 'w') + if bodytxt: + bodyfilename = os.path.join(path, '%s_body.sql' % description.unqualified_name.lower()) + bodyfile = open(bodyfilename, 'w') if opts.get('num') is not None: txt = txt.splitlines() txt = centeredSlice(txt, center=opts.num+1, width=opts.width) txt = '\n'.join(txt) else: txt = 'REMARK BEGIN %s\n%s\nREMARK END\n' % (description.path, txt) + if bodytxt: + bodytxt = 'REMARK BEGIN %s\n%s\nREMARK END\n' % (description.path, bodytxt) self.poutput(txt) + if bodytxt: + if opts.dump: + bodyfile.write(bodytxt) + else: + self.poutput(bodytxt) if opts.full: for dependent_type in ('constraints', 'triggers', 'indexes'): if hasattr(description.dbobj, dependent_type): @@ -889,6 +904,9 @@ self.poutput('REMARK BEGIN\n%s\nREMARK END\n\n' % depobj.get_ddl()) if opts.dump: self.stdout.close() + if bodytxt: + bodyfile.close() + statekeeper.restore() if vc: subprocess.call(vc + [filename]) except: