comparison sqlpython.py @ 1:8fa146b9a2d7

reworking multiline
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Fri, 30 Nov 2007 16:44:26 -0500
parents 9c87fa772ec1
children 59903dcaf327
comparison
equal deleted inserted replaced
0:9c87fa772ec1 1:8fa146b9a2d7
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 class Statement(object): 123 stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % terminatorSearchString
124 prompt2 = ' > ' 124 stmtEndFinder = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL)
125 stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % sqlpython.terminatorSearchString 125 prompt2 = ' > '
126 stmtEnd = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL) 126
127 def __init__(self, firstline): 127 def finishStatement(firstline):
128 v_Lines = [] 128 lines = [firstline]
129 v_Line = firstline 129 while 1:
130 while 1: 130 m = stmtEndFinder.search(lines[-1])
131 m = self.stmtEnd.search(v_Line) 131 if m:
132 if m: 132 return '\n'.join(lines)
133 v_Line, self.outformat, suffix = m.groups() 133 lines.append(raw_input(prompt2))
134 v_Lines.append(v_Line) 134
135 self.query = '\n'.join(v_Lines) 135 def findTerminator(statement):
136 self.rowlimit = int(suffix or 0) 136 m = stmtEndFinder.search(statement)
137 return 137 return m.groups()
138 v_Lines.append(v_Line)
139 v_Line = raw_input(self.prompt2)
140 self.query = '\n'.join(v_Lines)
141 138
142 def pmatrix(rows,desc,maxlen=30): 139 def pmatrix(rows,desc,maxlen=30):
143 '''prints a matrix, used by sqlpython to print queries' result sets''' 140 '''prints a matrix, used by sqlpython to print queries' result sets'''
144 names = [] 141 names = []
145 maxen = [] 142 maxen = []