comparison sqlpython.py @ 115:43f5dc75b791

migrating to onecmd from select
author catherine@Elli.myhome.westell.com
date Sat, 28 Jun 2008 11:10:09 -0400
parents c1c05670b4e5
children
comparison
equal deleted inserted replaced
114:c1c05670b4e5 115:43f5dc75b791
105 \\s CSV (with headings) 105 \\s CSV (with headings)
106 \\S CSV (no headings) 106 \\S CSV (no headings)
107 \\t transposed 107 \\t transposed
108 \\x XML""" 108 \\x XML"""
109 print self.do_terminators.__doc__ 109 print self.do_terminators.__doc__
110 110
111 terminatorSearchString = '|'.join('\\' + d.split()[0] for d in do_terminators.__doc__.splitlines())
112
113 def do_yasql(self, arg): 111 def do_yasql(self, arg):
114 '''Sends a command to a YASQL session (http://sourceforge.net/projects/yasql/)''' 112 '''Sends a command to a YASQL session (http://sourceforge.net/projects/yasql/)'''
115 self.designated_session(arg, pexpecter.YASQLSession) 113 self.designated_session(arg, pexpecter.YASQLSession)
116 do_y = do_yasql 114 do_y = do_yasql
117 def do_sqlplus(self, arg): 115 def do_sqlplus(self, arg):
134 self.fail(arg, do_everywhere = True ) 132 self.fail(arg, do_everywhere = True )
135 except Exception, e: 133 except Exception, e:
136 result = self.fail(arg) 134 result = self.fail(arg)
137 if not result: 135 if not result:
138 print str(e) 136 print str(e)
139 137
140 def do_commit(self, arg):
141 self.default('commit %s;' % (arg), do_everywhere=True)
142 def do_rollback(self, arg):
143 self.default('rollback %s;' % (arg), do_everywhere=True)
144
145 # shortcuts 138 # shortcuts
146 do_exit = cmd2.Cmd.do_quit 139 do_exit = cmd2.Cmd.do_quit
147
148 stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % terminatorSearchString
149 statementEndPattern = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL)
150 140
151 def pmatrix(rows,desc,maxlen=30): 141 def pmatrix(rows,desc,maxlen=30):
152 '''prints a matrix, used by sqlpython to print queries' result sets''' 142 '''prints a matrix, used by sqlpython to print queries' result sets'''
153 names = [] 143 names = []
154 maxen = [] 144 maxen = []