summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorVictor Uriarte <victor.m.uriarte@intel.com>2016-06-13 13:21:20 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-15 13:28:22 -0700
commita795be1a70a241e177227b742269fb2df88af962 (patch)
tree6c5c86555d1bd0168280a38bd8afac7939f3811a /examples
parent997f95b8b6ec5129362dcfe5deedaf50800e3afc (diff)
downloadsqlparse-a795be1a70a241e177227b742269fb2df88af962.tar.gz
Change token_ funcs to token_idx funcs
Diffstat (limited to 'examples')
-rw-r--r--examples/column_defs_lowlevel.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/column_defs_lowlevel.py b/examples/column_defs_lowlevel.py
index 5e98be3..1ebd065 100644
--- a/examples/column_defs_lowlevel.py
+++ b/examples/column_defs_lowlevel.py
@@ -17,16 +17,16 @@ def extract_definitions(token_list):
definitions = []
tmp = []
# grab the first token, ignoring whitespace. idx=1 to skip open (
- token = token_list.token_next(1)
+ tidx, token = token_list.token_idx_next(1)
while token and not token.match(sqlparse.tokens.Punctuation, ')'):
tmp.append(token)
# grab the next token, this times including whitespace
- token = token_list.token_next(token, skip_ws=False)
+ tidx, token = token_list.token_idx_next(tidx, skip_ws=False)
# split on ",", except when on end of statement
if token and token.match(sqlparse.tokens.Punctuation, ','):
definitions.append(tmp)
tmp = []
- token = token_list.token_next(token)
+ tidx, token = token_list.token_idx_next(tidx)
if tmp and isinstance(tmp[0], sqlparse.sql.Identifier):
definitions.append(tmp)
return definitions
@@ -41,7 +41,7 @@ if __name__ == '__main__':
parsed = sqlparse.parse(SQL)[0]
# extract the parenthesis which holds column definitions
- par = parsed.token_next_by(i=sqlparse.sql.Parenthesis)
+ _, par = parsed.token_idx_next_by(i=sqlparse.sql.Parenthesis)
columns = extract_definitions(par)
for column in columns: