# HG changeset patch # User catherine@dellzilla # Date 1268944519 14400 # Node ID 99734f5dded592f280be4c486c2c66d14d9d2838 # Parent ad07a08cb792ca3bf40ad326765f5913dd49cfb7 diff -r ad07a08cb792 -r 99734f5dded5 sqlpython/connections.py --- 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('.') diff -r ad07a08cb792 -r 99734f5dded5 sqlpython/mysqlpy.py --- 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 diff -r ad07a08cb792 -r 99734f5dded5 sqlpython/sqlpyPlus.py --- 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: