comparison sqlpython.py @ 40:1fb9f7dee7d8

tearing out cmd2
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Fri, 18 Jan 2008 15:07:10 -0500
parents 2776755a3a7e
children 33c9bc61db66
comparison
equal deleted inserted replaced
39:5d29e6a21c6f 40:1fb9f7dee7d8
12 import pexpecter 12 import pexpecter
13 13
14 # complication! separate sessions -> 14 # complication! separate sessions ->
15 # separate transactions !!!!! 15 # separate transactions !!!!!
16 # also: timeouts, other session failures 16 # also: timeouts, other session failures
17 17
18 class sqlpython(cmd2.Cmd): 18 class sqlpython(cmd2.Cmd):
19 '''A python module to reproduce Oracle's command line with focus on customization and extention''' 19 '''A python module to reproduce Oracle's command line with focus on customization and extention'''
20 20
21 def __init__(self): 21 def __init__(self):
22 cmd2.Cmd.__init__(self) 22 cmd2.Cmd.__init__(self)
118 118
119 # shortcuts 119 # shortcuts
120 do_q = do_quit 120 do_q = do_quit
121 do_exit = do_quit 121 do_exit = do_quit
122 122
123 stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % sqlpython.terminatorSearchString 123 stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % sqlpython.terminatorSearchString
124 stmtEndFinder = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL) 124 statementEndPattern = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL)
125 prompt2 = ' > '
126
127 def finishStatement(firstline):
128 lines = [firstline]
129 while 1:
130 m = stmtEndFinder.search(lines[-1])
131 if m:
132 return '\n'.join(lines)
133 lines.append(raw_input(prompt2))
134
135 def findTerminator(statement):
136 m = stmtEndFinder.search(statement)
137 if m:
138 return m.groups()
139 else:
140 return statement, None, None
141 125
142 def pmatrix(rows,desc,maxlen=30): 126 def pmatrix(rows,desc,maxlen=30):
143 '''prints a matrix, used by sqlpython to print queries' result sets''' 127 '''prints a matrix, used by sqlpython to print queries' result sets'''
144 names = [] 128 names = []
145 maxen = [] 129 maxen = []