Show More
@@ -10,18 +10,28 b' def color_sql(sql):' | |||||
10 | normal = '\x1b[0m' |
|
10 | normal = '\x1b[0m' | |
11 | return COLOR_SEQ % COLOR_SQL + sql + normal |
|
11 | return COLOR_SEQ % COLOR_SQL + sql + normal | |
12 |
|
12 | |||
|
13 | def one_space_trim(s): | |||
|
14 | if s.find(" ") == -1: | |||
|
15 | return s | |||
|
16 | else: | |||
|
17 | s = s.replace(' ', ' ') | |||
|
18 | return one_space_trim(s) | |||
|
19 | ||||
13 | def format_sql(sql): |
|
20 | def format_sql(sql): | |
14 | sql = color_sql(sql) |
|
21 | sql = color_sql(sql) | |
15 |
sql = sql.replace(' |
|
22 | sql = sql.replace('\n', '') | |
16 | .replace('FROM', '\n FROM')\ |
|
23 | sql = one_space_trim(sql) | |
17 | .replace('ORDER BY', '\n ORDER BY')\ |
|
24 | sql = sql\ | |
18 |
.replace(' |
|
25 | .replace('SELECT', '\n\tSELECT \n\t')\ | |
19 |
.replace(' |
|
26 | .replace('FROM', '\n\tFROM')\ | |
20 |
.replace(' |
|
27 | .replace('ORDER BY', '\n\tORDER BY')\ | |
21 |
.replace('L |
|
28 | .replace('LIMIT', '\n\tLIMIT')\ | |
22 |
.replace(' |
|
29 | .replace('WHERE', '\n\tWHERE')\ | |
23 |
.replace(' |
|
30 | .replace('AND', '\n\tAND')\ | |
24 |
.replace(' |
|
31 | .replace('LEFT', '\n\tLEFT')\ | |
|
32 | .replace('INNER', '\n\tINNER')\ | |||
|
33 | .replace('INSERT', '\n\tINSERT')\ | |||
|
34 | .replace('DELETE', '\n\tDELETE') | |||
25 | return sql |
|
35 | return sql | |
26 |
|
36 | |||
27 |
|
37 |
General Comments 0
You need to be logged in to leave comments.
Login now